@@ -70,6 +70,21 @@ export const VideoRow = function ({title, videos, ...props}) {
7070 }
7171 }
7272
73+ useLayoutEffect ( ( ) => {
74+ const observer = window . lozad ( '.lozad' , {
75+ load : ( el ) => {
76+ el . src = el . getAttribute ( 'data-src' ) ;
77+ // Custom implementation to load an element
78+ // e.g. el.src = el.getAttribute('data-src');
79+ } ,
80+ loaded : ( el ) => {
81+ el . removeAttribute ( 'poster' )
82+ el . classList . add ( 'loaded' ) ;
83+ }
84+ } ) ; // lazy loads elements with default selector as '.lozad'
85+ observer . observe ( ) ;
86+ } )
87+
7388 return (
7489 < div className = "margin-top--log margin-bottom--log" >
7590 {
@@ -82,22 +97,22 @@ export const VideoRow = function ({title, videos, ...props}) {
8297 < div className = { clsx ( 'col col--4' ) } key = { index } >
8398 < div >
8499 < video
85- src = { video . src }
86- /* poster="/static/img/Play.PNG"*/
87- className = { clsx ( styles . video ) }
88- onClick = { ( ) => openModal ( video ) } >
89- < source src = { video . src } type = "video/mp4" />
90- </ video >
100+ type = " video/mp4"
101+ poster = "/static/img/Play.PNG"
102+ data-src = { video . src }
103+ className = { clsx ( styles . video , 'lozad' ) }
104+ onClick = { ( ) => openModal ( video ) }
105+ / >
91106 < p className = { clsx ( 'text--center' , isDarkTheme && styles . headerFontTitle ) } > { video . title } </ p >
92107 </ div >
93-
108+
94109 { /*
95110 < div className={clsx(styles.videoName)}>
96111 <p className={clsx('text--left', isDarkTheme && styles.headerFontNum)}>by CodeLab</p>
97112 <p className={clsx('text--center', isDarkTheme && styles.headerFontTitle)}>{video.title}</p>
98113 </div>
99114 */ }
100-
115+
101116 </ div >
102117 ) )
103118 }
@@ -143,13 +158,13 @@ function Projects() {
143158 { /*
144159 <span className={clsx(styles.fancytitle1, 'stack')}>Let's </span>
145160 <span className={clsx(styles.fancytitle1, 'stack')}> Play!</span>
146-
161+
147162 <h1 className={clsx(styles.fancytitle2, 'stack')}>无惧简陋与粗糙</h1>
148163 */ }
149164 < h1 className = { clsx ( styles . fancytitle2 , 'stack' ) } > 在玩乐中创作与表达</ h1 >
150165 </ div >
151166 < main className = { clsx ( "container" ) } >
152- < VideoRow title = "" videos = { videos [ '来自CodeLab' ] } />
167+ < VideoRow title = "" videos = { videos [ '来自CodeLab' ] } />
153168 < VideoRow title = "" videos = { videos [ '来自社区' ] } />
154169 </ main >
155170 </ div >
0 commit comments