SHARE
TWEET

Untitled

a guest Aug 20th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var target = $('.elem');
  2. var targetPos = target.offset().top;
  3. var winHeight = $(window).height();
  4. var scrollToElem = targetPos - winHeight;
  5. $(window).scroll(function(){
  6.   var winScrollTop = $(this).scrollTop();
  7.   if(winScrollTop > scrollToElem){
  8.     //сработает когда пользователь доскроллит к элементу с классом .elem
  9.   }
  10. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top