SHARE
TWEET

Untitled

a guest Sep 20th, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function () {
  2.         let $scrollDoc,
  3.             $basketBtn = $('#vmCartModule-sticky-wrapper'),
  4.             $basketTop = $('#vmCartModule-sticky-wrapper').offset().top,
  5.             rightContainer = $('.container')[0].getBoundingClientRect().right,
  6.             widthDocument = document.documentElement.clientWidth,
  7.             widthContainer = $('.container').outerWidth();
  8.         let widthBtnBasket = $basketBtn.outerWidth();
  9.  
  10.  
  11.         $(window).scroll(function () {
  12.             $scrollDoc = $(window).scrollTop();
  13.  
  14.             if ($scrollDoc > $basketTop) {
  15.                 if (((widthDocument - widthContainer) / 2) > widthBtnBasket) {
  16.                     $basketBtn.css({
  17.                         'position': 'fixed',
  18.                         'left': (Math.ceil(rightContainer - 10)) + 'px',
  19.                         'top': 0,
  20.  
  21.  
  22.                     });
  23.                 } else {
  24.                     $basketBtn.css({
  25.                         'position': 'fixed',
  26.                         'right': 0,
  27.                         'top': 0,
  28.  
  29.  
  30.                     });
  31.                 }
  32.  
  33.  
  34.             } else {
  35.  
  36.                 $basketBtn.css('position', 'static');
  37.             }
  38.         });
  39.     });
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top