docs/odo-scroll-feedback/scripts/demo.js
function scrollToIndex(index) {
    var duration = 400;
    var start = window.pageYOffset;
    var end = index * window.innerHeight;
    var amount = end - start;
    var startTime = +new Date();

    var easing = function easing(k) {
      return -0.5 * (Math.cos(Math.PI * k) - 1);
    };

    var step = function step(value /* , percent */) {
      window.scrollTo(0, value);
    };

    var complete = function complete() {
      isScrolling = false;
    };

    var looper = function looper() {
      var now = +new Date();
      var remainingTime = startTime + duration - now;
      var percent = 1 - (remainingTime / duration || 0);

      // Abort if already past 100%.
      if (percent >= 1) {
        // Make sure it always finishes with 1.
        step(end, 1);
        complete();
        return;
      }

      // Apply easing.
      percent = easing(percent);

      // Tick.
      step(start + amount * percent, percent);

      // Request animation frame.
      requestAnimationFrame(looper);
    };

    isScrolling = true;
    requestAnimationFrame(looper);
  }
function scrollToIndex(index) {
    var duration = 400;
    var start = window.pageYOffset;
    var end = index * window.innerHeight;
    var amount = end - start;
    var startTime = +new Date();

    var easing = function easing(k) {
      return -0.5 * (Math.cos(Math.PI * k) - 1);
    };

    var step = function step(value /* , percent */) {
      window.scrollTo(0, value);
    };

    var complete = function complete() {
      isScrolling = false;
    };

    var looper = function looper() {
      var now = +new Date();
      var remainingTime = startTime + duration - now;
      var percent = 1 - (remainingTime / duration || 0);

      // Abort if already past 100%.
      if (percent >= 1) {
        // Make sure it always finishes with 1.
        step(end, 1);
        complete();
        return;
      }

      // Apply easing.
      percent = easing(percent);

      // Tick.
      step(start + amount * percent, percent);

      // Request animation frame.
      requestAnimationFrame(looper);
    };

    isScrolling = true;
    requestAnimationFrame(looper);
  }
function scrollToIndex ( index ) { var duration = 400 ; var start = window . pageYOffset ; var end = index * window . innerHeight ; var amount = end - start ; var startTime = + new Date ( ) ; var easing = function easing ( k ) { return - 0.5 * ( Math . cos ( Math . PI * k ) - 1 ) ; } ; var step = function step ( value /* , percent */ ) { window . scrollTo ( 0 , value ) ; } ; var complete = function complete ( ) { isScrolling = false ; } ; var looper = function looper ( ) { var now = + new Date ( ) ; var remainingTime = startTime + duration - now ; var percent = 1 - ( remainingTime / duration || 0 ) ; // Abort if already past 100%. if ( percent >= 1 ) { // Make sure it always finishes with 1. step ( end , 1 ) ; complete ( ) ; return ; } // Apply easing. percent = easing ( percent ) ; // Tick. step ( start + amount * percent , percent ) ; // Request animation frame. requestAnimationFrame ( looper ) ; } ; isScrolling = true ; requestAnimationFrame ( looper ) ; }
Animate scrolling the page - without jQuery. Code adapted from DualViewer's stepper.js
Animate scrolling the page - without jQuery . Code adapted from DualViewer s stepper . js