File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,12 +62,11 @@ <h1>Slide in on Scroll</h1>
6262
6363 function checkSlide ( e ) {
6464 sliderImages . forEach ( sliderImage => {
65- // half way through the image
66- const slideInAt = ( window . scrollY + window . innerHeight ) - sliderImage . height / 2 ;
67- // bottom of the image
65+ const slideInAt = ( window . scrollY + window . innerHeight ) - ( sliderImage . height / 2 ) ;
6866 const imageBottom = sliderImage . offsetTop + sliderImage . height ;
6967 const isHalfShown = slideInAt > sliderImage . offsetTop ;
7068 const isNotScrolledPast = window . scrollY < imageBottom ;
69+
7170 if ( isHalfShown && isNotScrolledPast ) {
7271 sliderImage . classList . add ( 'active' ) ;
7372 } else {
@@ -77,7 +76,6 @@ <h1>Slide in on Scroll</h1>
7776 }
7877
7978 window . addEventListener ( 'scroll' , debounce ( checkSlide ) ) ;
80-
8179 </ script >
8280
8381 < style >
You can’t perform that action at this time.
0 commit comments