intro.js
/*
     * Scrolls to a destination on the Y axis, with an InOut easing animation.
     * @api private
     * @param {Number} destinationYPosition Y-position to scroll to
     */
Scrolls to a destination on the Y axis, with an InOut easing animation.
@api private
@param {Number} destinationYPosition Y-position to scroll to
Scrolls to a destination on the Y axis with an InOut easing animation . @api private @param { Number } destinationYPosition Y - position to scroll to
function _smoothScroll(destinationYPosition) {
        var duration = 1000;
        var startTime = Date.now();
        var currentYPosition = _getCurrentYPosition();
        var min = function(a, b) {
            return a < b ? a : b;
        };
        var requestAnimationFrame = function(fn) {
            if (window.requestAnimationFrame) {
                window.requestAnimationFrame(fn);
            } else {
                window.setTimeout(fn, 10);
            }
        };
        var easeInOutFunction = function(t) {
            return t < 0.5 ? (16 * t * t * t * t * t) : (1 + 16 * (--t) * t * t * t * t);
        };
        var stepFunction = function() {
            var currentTime = Date.now();
            var time = min(1, ((currentTime - startTime) / duration));
            var easedTime = easeInOutFunction(time);
            window.scrollTo(0, (easedTime * (destinationYPosition - currentYPosition)) + currentYPosition);
            if (time < 1) {
                requestAnimationFrame(stepFunction);
            }
        };
        requestAnimationFrame(stepFunction);
    }
function _smoothScroll ( destinationYPosition ) { var duration = 1000 ; var startTime = Date . now ( ) ; var currentYPosition = _getCurrentYPosition ( ) ; var min = function ( a , b ) { return a < b ? a : b ; } ; var requestAnimationFrame = function ( fn ) { if ( window . requestAnimationFrame ) { window . requestAnimationFrame ( fn ) ; } else { window . setTimeout ( fn , 10 ) ; } } ; var easeInOutFunction = function ( t ) { return t < 0.5 ? ( 16 * t * t * t * t * t ) : ( 1 + 16 * ( -- t ) * t * t * t * t ) ; } ; var stepFunction = function ( ) { var currentTime = Date . now ( ) ; var time = min ( 1 , ( ( currentTime - startTime ) / duration ) ) ; var easedTime = easeInOutFunction ( time ) ; window . scrollTo ( 0 , ( easedTime * ( destinationYPosition - currentYPosition ) ) + currentYPosition ) ; if ( time < 1 ) { requestAnimationFrame ( stepFunction ) ; } } ; requestAnimationFrame ( stepFunction ) ; }
Scrolls to a destination on the Y axis, with an InOut easing animation.
Scrolls to a destination on the Y axis with an InOut easing animation .
// acceleration until halfway, then deceleration // based on: http://gizma.com/easing/#quint3