Skip to content

Commit 2d877e6

Browse files
Add files via upload
1 parent 9334542 commit 2d877e6

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

index.html

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,35 @@
2525
text-align: center;
2626
}
2727
</style>
28+
<script>
29+
function loadVideo(element) {
30+
const iframe = element.querySelector('iframe');
31+
const src = iframe.getAttribute('data-src');
32+
iframe.setAttribute('src', src);
33+
}
34+
35+
function handleIntersection(entries, observer) {
36+
entries.forEach((entry) => {
37+
if (entry.isIntersecting) {
38+
loadVideo(entry.target);
39+
observer.unobserve(entry.target);
40+
}
41+
});
42+
}
43+
44+
const videoSections = document.querySelectorAll('section');
45+
46+
const options = {
47+
rootMargin: '0px',
48+
threshold: 0.1
49+
};
50+
51+
const observer = new IntersectionObserver(handleIntersection, options);
52+
53+
videoSections.forEach((section) => {
54+
observer.observe(section);
55+
});
56+
</script>
2857
</head>
2958
<body>
3059
<header>
@@ -47,13 +76,13 @@ <h1>SML Archive</h1>
4776
<h2>Videos</h2>
4877
<!-- Embedded video with auto scaling -->
4978
<div class="video-container">
50-
<iframe src="https://www.youtube.com/embed/6w8QkUBx0qc" frameborder="0" allowfullscreen></iframe>
79+
<iframe data-src="https://www.youtube.com/embed/6w8QkUBx0qc" frameborder="0" allowfullscreen></iframe>
5180
</div>
5281
<p>SML Movie: Chef Pee Pee Quits Part 2</p>
5382
</section>
5483
<section>
5584
<div class="video-container">
56-
<iframe src="https://www.youtube.com/embed/lbqEPZI0-zA" frameborder="0" allowfullscreen></iframe>
85+
<iframe data-src="https://www.youtube.com/embed/lbqEPZI0-zA" frameborder="0" allowfullscreen></iframe>
5786
</div>
5887
<p>SML Movie: Black Yoshi's Big Bamboozle [REUPLOADED] - YouTube</p>
5988
</section>

0 commit comments

Comments
 (0)