Skip to content

Commit 7f68213

Browse files
committed
update
1 parent 9e0ac5c commit 7f68213

2 files changed

Lines changed: 119 additions & 15 deletions

File tree

js/site.js

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,118 @@
11
// Showreel slider
2+
23
(function() {
4+
35
const container = document.getElementById('showreel');
6+
47
if (!container) return;
58

9+
610
const slides = Array.from(container.querySelectorAll('.slide'));
11+
712
if (slides.length === 0) return;
813

14+
915
let currentIndex = 0;
1016

11-
// Show first slide immediately
17+
18+
// إظهار أول شريحة فوراً
19+
1220
slides[0].classList.add('active');
13-
14-
// Preload first video if exists
21+
22+
23+
// تشغيل أول فيديو لو موجود
24+
1525
const firstVideo = slides[0].querySelector('video');
26+
1627
if (firstVideo) {
17-
firstVideo.load();
28+
1829
firstVideo.play().catch(() => {});
30+
1931
}
2032

33+
2134
function showSlide(index) {
35+
2236
slides.forEach((s, i) => {
37+
2338
s.classList.toggle('active', i === index);
39+
2440
const video = s.querySelector('video');
41+
42+
2543
if (video) {
44+
2645
if (i === index) {
46+
47+
// تشغيل الفيديو للشريحة النشطة فقط
48+
2749
video.currentTime = 0;
50+
2851
video.play().catch(() => {});
52+
2953
} else {
54+
55+
// إيقاف الفيديوهات في الشرائح المخفية لتوفير الأداء
56+
3057
video.pause();
58+
3159
}
60+
3261
}
62+
3363
});
64+
3465
}
3566

67+
3668
function nextSlide() {
69+
3770
currentIndex = (currentIndex + 1) % slides.length;
71+
3872
showSlide(currentIndex);
73+
3974
}
4075

41-
// Start rotation after 5 seconds
76+
77+
// تغيير الشريحة كل 5 ثواني
78+
4279
setInterval(nextSlide, 5000);
80+
4381
})();
82+
83+
84+
// Facade Pattern for Vimeo videos
85+
86+
document.addEventListener("DOMContentLoaded", function () {
87+
88+
const videoWrappers = document.querySelectorAll(".video-wrapper");
89+
90+
91+
videoWrappers.forEach((wrapper) => {
92+
93+
const playButton = wrapper.querySelector(".facade-play-btn");
94+
95+
const iframe = wrapper.querySelector("iframe");
96+
97+
98+
if (playButton) {
99+
100+
playButton.addEventListener("click", function () {
101+
102+
playButton.style.display = "none"; // إخفاء الزر
103+
104+
if (iframe) {
105+
106+
iframe.src = iframe.dataset.src; // تعيين src للإطار
107+
108+
}
109+
110+
wrapper.style.cursor = "default";
111+
112+
});
113+
114+
}
115+
116+
});
117+
118+
})

projects/short-film-projects.njk

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
---
2-
layout: layouts/home.njk
2+
layout: layouts/base.njk
33
title: Short Film Projects
44
---
55

66
<div class="w3-padding-64 w3-content">
77
<h2 class="w3-text-light-grey">Short Film Projects</h2>
8-
<!-- <hr style="width:200px" class="w3-opacity"> -->
98

10-
{# بنمشي على كل المشاريع المعلّمة tag "project" ونعكس الترتيب عشان الأحدث يظهر الأول #}
119
{% for p in (collections.project or []) | reverse %}
1210
{% if (p.data.section or '').toLowerCase() == 'short film projects' %}
1311
<div class="film-project w3-margin-bottom">
14-
1512
<h3 class="w3-text-light-grey" style="margin:18px 0 8px;">{{ p.data.title }}</h3>
1613

1714
{% if p.data.vimeoId %}
18-
<div class="video-wrapper" style="margin:12px 0;">
15+
<div class="video-wrapper" style="aspect-ratio: 16 / 9; width: 100%; background-image: url('https://vumbnail.com/{{ p.data.vimeoId }}.jpg'); background-size: cover; background-position: center; cursor: pointer; position: relative;">
16+
<button class="facade-play-btn" type="button" aria-label="Play video">
17+
<svg viewBox="0 0 24 24" width="40" height="40" aria-hidden="true">
18+
<path d="M8 5.2v13.6L19 12z" fill="currentColor"/>
19+
</svg>
20+
</button>
1921
<iframe
20-
class="lazyload"
21-
data-src="https://player.vimeo.com/video/{{ p.data.vimeoId }}?background=1&autoplay=1&loop=1&muted=1"
22-
width="100%" height="420" frameborder="0"
23-
loading="lazy"
22+
data-src="https://player.vimeo.com/video/{{ p.data.vimeoId }}?autoplay=1&color=ffffff&title=0&byline=0&portrait=0"
23+
width="100%" height="100%" frameborder="0"
24+
class="lazy-vimeo"
2425
allow="autoplay; fullscreen; picture-in-picture"
2526
allowfullscreen>
2627
</iframe>
2728
</div>
2829
{% endif %}
2930

30-
{# لو محتوى الصفحة فيه تفاصيل نصية (التاريخ/الأدوات/ملاحظات) هتظهر هنا #}
3131
{% if p.templateContent %}
3232
<div class="w3-text-grey" style="line-height:1.7;">
3333
{{ p.templateContent | safe }}
@@ -39,3 +39,32 @@ title: Short Film Projects
3939
{% endif %}
4040
{% endfor %}
4141
</div>
42+
43+
<style>
44+
.facade-play-btn {
45+
position: absolute;
46+
top: 50%;
47+
left: 50%;
48+
transform: translate(-50%, -50%);
49+
width: 70px;
50+
height: 70px;
51+
background: rgba(0, 0, 0, 0.7);
52+
border-radius: 50%;
53+
display: flex;
54+
align-items: center;
55+
justify-content: center;
56+
cursor: pointer;
57+
z-index: 2;
58+
border: none;
59+
transition: transform 0.3s ease, background-color 0.3s ease;
60+
}
61+
62+
.facade-play-btn:hover {
63+
transform: translate(-50%, -50%) scale(1.15);
64+
background-color: rgba(0, 0, 0, 0.9);
65+
}
66+
67+
.facade-play-btn svg {
68+
fill: #fff;
69+
}
70+
</style>

0 commit comments

Comments
 (0)