25
25
text-align : center;
26
26
}
27
27
</ 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 >
28
57
</ head >
29
58
< body >
30
59
< header >
@@ -47,13 +76,13 @@ <h1>SML Archive</h1>
47
76
< h2 > Videos</ h2 >
48
77
<!-- Embedded video with auto scaling -->
49
78
< 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 >
51
80
</ div >
52
81
< p > SML Movie: Chef Pee Pee Quits Part 2</ p >
53
82
</ section >
54
83
< section >
55
84
< 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 >
57
86
</ div >
58
87
< p > SML Movie: Black Yoshi's Big Bamboozle [REUPLOADED] - YouTube</ p >
59
88
</ section >
0 commit comments