diff --git a/lib/js/index.js b/lib/js/index.js index 0785fe2..c51c4ea 100644 --- a/lib/js/index.js +++ b/lib/js/index.js @@ -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