Spaces:
Running
Running
Update script.js
Browse files
script.js
CHANGED
|
@@ -8,7 +8,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 8 |
}
|
| 9 |
});
|
| 10 |
}, {
|
| 11 |
-
threshold: 0.
|
| 12 |
});
|
| 13 |
sections.forEach(section => {
|
| 14 |
sectionObserver.observe(section);
|
|
@@ -48,10 +48,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 48 |
// --- ★★★★★ 修正並簡化後的燈箱功能 ★★★★★ ---
|
| 49 |
document.body.addEventListener('click', function(event) {
|
| 50 |
// 檢查點擊的是否是帶有 .lightbox-trigger 的 <a> 標籤
|
| 51 |
-
|
|
|
|
| 52 |
event.preventDefault(); // 阻止連結的默認跳轉行為
|
| 53 |
|
| 54 |
-
const trigger = event.target.closest('.lightbox-trigger');
|
| 55 |
const imageUrl = trigger.getAttribute('href');
|
| 56 |
|
| 57 |
// 如果頁面上已經有燈箱,就不要再創建
|
|
|
|
| 8 |
}
|
| 9 |
});
|
| 10 |
}, {
|
| 11 |
+
threshold: 0.05 // *** 降低觸發門檻,修復手機版底部區塊無法顯示問題 ***
|
| 12 |
});
|
| 13 |
sections.forEach(section => {
|
| 14 |
sectionObserver.observe(section);
|
|
|
|
| 48 |
// --- ★★★★★ 修正並簡化後的燈箱功能 ★★★★★ ---
|
| 49 |
document.body.addEventListener('click', function(event) {
|
| 50 |
// 檢查點擊的是否是帶有 .lightbox-trigger 的 <a> 標籤
|
| 51 |
+
const trigger = event.target.closest('.lightbox-trigger');
|
| 52 |
+
if (trigger) {
|
| 53 |
event.preventDefault(); // 阻止連結的默認跳轉行為
|
| 54 |
|
|
|
|
| 55 |
const imageUrl = trigger.getAttribute('href');
|
| 56 |
|
| 57 |
// 如果頁面上已經有燈箱,就不要再創建
|