fix: such errors are worse

This commit is contained in:
Harsh Khandeparkar 2020-06-29 11:31:52 +05:30 committed by GitHub
parent c49c681931
commit 5508f0f7d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,9 +3,8 @@ const depthFactor = 5; // Depth of the image wrt to the 0 z-index. Infinity bein
const parallaxOffset = 20;
$(window).on('scroll', () => {
const movedBy = window.scrollY;
if ($(window).height() - parallax.getBoundingClientRect().top >= parallaxOffset) {
$('.parallax').each((i, parallax) => {
$('.parallax').each((i, parallax) => {
if ($(window).height() - parallax.getBoundingClientRect().top >= parallaxOffset) {
$(parallax).find('.parallax-layer').each((i, layer) => {
const depth = $(layer).attr('data-depth-factor') || depthFactor; // dynamically get depthFactor
@ -13,8 +12,8 @@ $(window).on('scroll', () => {
transform: `translateY(+${movedBy / depth}px)` // Move differently than the rest of the window
})
})
})
}
}
})
})
// /Parallax