(e)
| 16 | const sliderImages = document.querySelectorAll('.slide-in'); |
| 17 | |
| 18 | function checkSlide(e) { |
| 19 | sliderImages.forEach(sliderImage => { |
| 20 | //half way through the image |
| 21 | const slideInAt = (window.scrollY + window.innerHeight) - sliderImage.height/2; |
| 22 | // bottom of the image |
| 23 | const imageBottom = sliderImage.offsetTop + sliderImage.height; |
| 24 | const isHalfShown = slideInAt > sliderImage.offsetTop; |
| 25 | const isNotScrolledPast = window.scrollY < imageBottom; |
| 26 | if (isHalfShown && isNotScrolledPast) |
| 27 | { |
| 28 | sliderImage.classList.add('active'); |
| 29 | } |
| 30 | else{ |
| 31 | sliderImage.classList.remove('active'); |
| 32 | } |
| 33 | |
| 34 | }); |
| 35 | } |
| 36 | |
| 37 | window.addEventListener('scroll', debounce(checkSlide)); |
nothing calls this directly
no outgoing calls
no test coverage detected