Skip to content

Commit

Permalink
fix(lazy): use passive listener for scroll listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed May 28, 2021
1 parent 5d9a093 commit cbe7a59
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/lazy/lazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,19 @@ const Lazy = {
}
}

const passiveListener =
swiper.touchEvents.start === 'touchstart' &&
swiper.support.passiveListener &&
swiper.params.passiveListeners
? { passive: true, capture: false }
: false;

if (inView) {
swiper.lazy.load();
$scrollElement.off('scroll', swiper.lazy.checkInViewOnLoad);
$scrollElement.off('scroll', swiper.lazy.checkInViewOnLoad, passiveListener);
} else if (!swiper.lazy.scrollHandlerAttached) {
swiper.lazy.scrollHandlerAttached = true;
$scrollElement.on('scroll', swiper.lazy.checkInViewOnLoad);
$scrollElement.on('scroll', swiper.lazy.checkInViewOnLoad, passiveListener);
}
},
};
Expand Down

0 comments on commit cbe7a59

Please sign in to comment.