artemsemkin

Cassio modified scroll down distance

Mar 22nd, 2021 (edited)
902
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var ScrollDown = function () {
  2.  
  3.   var $el = $('.js-scroll-down');
  4.  
  5.   if (!$el.length) {
  6.     return;
  7.   }
  8.  
  9.   $el.on('click', function (e) {
  10.  
  11.     // this takes into consideration the header height
  12.     // if you'd like you can replace "$('#page-header').height()" with
  13.     // any number in pixels, e.g. "75"
  14.     // Example:
  15.     // var distance = window.innerHeight - 75;
  16.     var distance = window.innerHeight - $('#page-header').height();
  17.  
  18.  
  19.     e.preventDefault();
  20.  
  21.     $('html, body').animate({
  22.       scrollTop: distance
  23.     }, 600, 'swing');
  24.  
  25.     if (window.SB !== undefined) {
  26.  
  27.       window.SB.scrollTo(0, distance, 1200, {
  28.         easing: function (pos) {
  29.           if (pos === 0) return 0;
  30.           if (pos === 1) return 1;
  31.           if ((pos /= 0.5) < 1) return 0.5 * Math.pow(2, 10 * (pos - 1));
  32.           return 0.5 * (-Math.pow(2, -10 * --pos) + 2);
  33.         }
  34.       });
  35.     }
  36.  
  37.   });
  38.  
  39. };
RAW Paste Data