From 5508f0f7d533c397371c7fda0966836b645c9203 Mon Sep 17 00:00:00 2001 From: Harsh Khandeparkar <34770591+HarshKhandeparkar@users.noreply.github.com> Date: Mon, 29 Jun 2020 11:31:52 +0530 Subject: [PATCH] fix: such errors are worse --- lib/js/index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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