Вход Регистрация
Файл: Source/assets/jscript/iscroll.js
Строк: 1944
<?php
/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
(function (windowdocumentMath) {
var 
rAF window.requestAnimationFrame    ||
    
window.webkitRequestAnimationFrame    ||
    
window.mozRequestAnimationFrame        ||
    
window.oRequestAnimationFrame        ||
    
window.msRequestAnimationFrame        ||
    function (
callback) { window.setTimeout(callback1000 60); };

var 
utils = (function () {
    var 
me = {};

    var 
_elementStyle document.createElement('div').style;
    var 
_vendor = (function () {
        var 
vendors = ['t''webkitT''MozT''msT''OT'],
            
transform,
            
0,
            
vendors.length;

        for ( ; 
li++ ) {
            
transform vendors[i] + 'ransform';
            if ( 
transform in _elementStyle ) return vendors[i].substr(0vendors[i].length-1);
        }

        return 
false;
    })();

    function 
_prefixStyle (style) {
        if ( 
_vendor === false ) return false;
        if ( 
_vendor === '' ) return style;
        return 
_vendor style.charAt(0).toUpperCase() + style.substr(1);
    }

    
me.getTime Date.now || function getTime () { return new Date().getTime(); };

    
me.extend = function (targetobj) {
        for ( var 
i in obj ) {
            
target[i] = obj[i];
        }
    };

    
me.addEvent = function (eltype, fn, capture) {
        
el.addEventListener(type, fn, !!capture);
    };

    
me.removeEvent = function (eltype, fn, capture) {
        
el.removeEventListener(type, fn, !!capture);
    };

    
me.momentum = function (currentstarttimelowerMarginwrapperSizedeceleration) {
        var 
distance current start,
            
speed Math.abs(distance) / time,
            
destination,
            
duration;

        
deceleration deceleration === undefined 0.0006 deceleration;

        
destination current + ( speed speed ) / ( deceleration ) * ( distance ? -);
        
duration speed deceleration;

        if ( 
destination lowerMargin ) {
            
destination wrapperSize lowerMargin - ( wrapperSize 2.5 * ( speed ) ) : lowerMargin;
            
distance Math.abs(destination current);
            
duration distance speed;
        } else if ( 
destination ) {
            
destination wrapperSize wrapperSize 2.5 * ( speed ) : 0;
            
distance Math.abs(current) + destination;
            
duration distance speed;
        }

        return {
            
destinationMath.round(destination),
            
durationduration
        
};
    };

    var 
_transform _prefixStyle('transform');

    
me.extend(me, {
        
hasTransform_transform !== false,
        
hasPerspective_prefixStyle('perspective'in _elementStyle,
        
hasTouch'ontouchstart' in window,
        
hasPointernavigator.msPointerEnabled,
        
hasTransition_prefixStyle('transition'in _elementStyle
    
});

    
// This should find all Android browsers lower than build 535.19 (both stock browser and webview)
    
me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome/d/.test(window.navigator.appVersion));

    
me.extend(me.style = {}, {
        
transform_transform,
        
transitionTimingFunction_prefixStyle('transitionTimingFunction'),
        
transitionDuration_prefixStyle('transitionDuration'),
        
transitionDelay_prefixStyle('transitionDelay'),
        
transformOrigin_prefixStyle('transformOrigin')
    });

    
me.hasClass = function (ec) {
        var 
re = new RegExp("(^|\s)" "(\s|$)");
        return 
re.test(e.className);
    };

    
me.addClass = function (ec) {
        if ( 
me.hasClass(ec) ) {
            return;
        }

        var 
newclass e.className.split(' ');
        
newclass.push(c);
        
e.className newclass.join(' ');
    };

    
me.removeClass = function (ec) {
        if ( !
me.hasClass(ec) ) {
            return;
        }

        var 
re = new RegExp("(^|\s)" "(\s|$)"'g');
        
e.className e.className.replace(re' ');
    };

    
me.offset = function (el) {
        var 
left = -el.offsetLeft,
            
top = -el.offsetTop;

        
// jshint -W084
        
while (el el.offsetParent) {
            
left -= el.offsetLeft;
            
top -= el.offsetTop;
        }
        
// jshint +W084

        
return {
            
leftleft,
            
toptop
        
};
    };

    
me.preventDefaultException = function (elexceptions) {
        for ( var 
i in exceptions ) {
            if ( 
exceptions[i].test(el[i]) ) {
                return 
true;
            }
        }

        return 
false;
    };

    
me.extend(me.eventType = {}, {
        
touchstart1,
        
touchmove1,
        
touchend1,

        
mousedown2,
        
mousemove2,
        
mouseup2,

        
MSPointerDown3,
        
MSPointerMove3,
        
MSPointerUp3
    
});

    
me.extend(me.ease = {}, {
        
quadratic: {
            
style'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
            fn: function (
k) {
                return 
* ( );
            }
        },
        
circular: {
            
style'cubic-bezier(0.1, 0.57, 0.1, 1)',    // Not properly "circular" but this looks better, it should be (0.075, 0.82, 0.165, 1)
            
fn: function (k) {
                return 
Math.sqrt- ( --) );
            }
        },
        
back: {
            
style'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
            fn: function (
k) {
                var 
4;
                return ( 
) * * ( ( ) * ) + 1;
            }
        },
        
bounce: {
            
style'',
            fn: function (
k) {
                if ( ( 
/= ) < ( 2.75 ) ) {
                    return 
7.5625 k;
                } else if ( 
< ( 2.75 ) ) {
                    return 
7.5625 * ( -= ( 1.5 2.75 ) ) * 0.75;
                } else if ( 
< ( 2.5 2.75 ) ) {
                    return 
7.5625 * ( -= ( 2.25 2.75 ) ) * 0.9375;
                } else {
                    return 
7.5625 * ( -= ( 2.625 2.75 ) ) * 0.984375;
                }
            }
        },
        
elastic: {
            
style'',
            fn: function (
k) {
                var 
0.22,
                    
0.4;

                if ( 
=== ) { return 0; }
                if ( 
== ) { return 1; }

                return ( 
Math.pow2, - 10 ) * Math.sin( ( ) * ( Math.PI ) / ) + );
            }
        }
    });

    
me.tap = function (eeventName) {
        var 
ev document.createEvent('Event');
        
ev.initEvent(eventNametruetrue);
        
ev.pageX e.pageX;
        
ev.pageY e.pageY;
        
e.target.dispatchEvent(ev);
    };

    
me.click = function (e) {
        var 
target e.target,
            
ev;

        if ( !(/(
SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
            
ev document.createEvent('MouseEvents');
            
ev.initMouseEvent('click'truetruee.view1,
                
target.screenXtarget.screenYtarget.clientXtarget.clientY,
                
e.ctrlKeye.altKeye.shiftKeye.metaKey,
                
0null);

            
ev._constructed true;
            
target.dispatchEvent(ev);
        }
    };

    return 
me;
})();

function 
IScroll (eloptions) {
    
this.wrapper typeof el == 'string' document.querySelector(el) : el;
    
this.scroller this.wrapper.children[0];
    
this.scrollerStyle this.scroller.style;        // cache style for better performance

    
this.options = {

        
resizeScrollbarstrue,

        
mouseWheelSpeed20,

        
snapThreshold0.334,

// INSERT POINT: OPTIONS 

        
startX0,
        
startY0,
        
scrollYtrue,
        
directionLockThreshold5,
        
momentumtrue,

        
bouncetrue,
        
bounceTime600,
        
bounceEasing'',

        
preventDefaulttrue,
        
preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ },

        
HWCompositingtrue,
        
useTransitiontrue,
        
useTransformtrue
    
};

    for ( var 
i in options ) {
        
this.options[i] = options[i];
    }

    
// Normalize options
    
this.translateZ this.options.HWCompositing && utils.hasPerspective ' translateZ(0)' '';

    
this.options.useTransition utils.hasTransition && this.options.useTransition;
    
this.options.useTransform utils.hasTransform && this.options.useTransform;

    
this.options.eventPassthrough this.options.eventPassthrough === true 'vertical' this.options.eventPassthrough;
    
this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault;

    
// If you want eventPassthrough I have to lock one of the axes
    
this.options.scrollY this.options.eventPassthrough == 'vertical' false this.options.scrollY;
    
this.options.scrollX this.options.eventPassthrough == 'horizontal' false this.options.scrollX;

    
// With eventPassthrough we also need lockDirection mechanism
    
this.options.freeScroll this.options.freeScroll && !this.options.eventPassthrough;
    
this.options.directionLockThreshold this.options.eventPassthrough this.options.directionLockThreshold;

    
this.options.bounceEasing typeof this.options.bounceEasing == 'string' utils.ease[this.options.bounceEasing] || utils.ease.circular this.options.bounceEasing;

    
this.options.resizePolling this.options.resizePolling === undefined 60 this.options.resizePolling;

    if ( 
this.options.tap === true ) {
        
this.options.tap 'tap';
    }

    if ( 
this.options.shrinkScrollbars == 'scale' ) {
        
this.options.useTransition false;
    }

    
this.options.invertWheelDirection this.options.invertWheelDirection ? -1;

// INSERT POINT: NORMALIZATION

    // Some defaults    
    
this.0;
    
this.0;
    
this.directionX 0;
    
this.directionY 0;
    
this._events = {};

// INSERT POINT: DEFAULTS

    
this._init();
    
this.refresh();

    
this.scrollTo(this.options.startXthis.options.startY);
    
this.enable();
}

IScroll.prototype = {
    
version'5.1.1',

    
_init: function () {
        
this._initEvents();

        if ( 
this.options.scrollbars || this.options.indicators ) {
            
this._initIndicators();
        }

        if ( 
this.options.mouseWheel ) {
            
this._initWheel();
        }

        if ( 
this.options.snap ) {
            
this._initSnap();
        }

        if ( 
this.options.keyBindings ) {
            
this._initKeys();
        }

// INSERT POINT: _init

    
},

    
destroy: function () {
        
this._initEvents(true);

        
this._execEvent('destroy');
    },

    
_transitionEnd: function (e) {
        if ( 
e.target != this.scroller || !this.isInTransition ) {
            return;
        }

        
this._transitionTime();
        if ( !
this.resetPosition(this.options.bounceTime) ) {
            
this.isInTransition false;
            
this._execEvent('scrollEnd');
        }
    },

    
_start: function (e) {
        
// React to left mouse button only
        
if ( utils.eventType[e.type] != ) {
            if ( 
e.button !== ) {
                return;
            }
        }

        if ( !
this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) {
            return;
        }

        if ( 
this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.targetthis.options.preventDefaultException) ) {
            
e.preventDefault();
        }

        var 
point e.touches e.touches[0] : e,
            
pos;

        
this.initiated    utils.eventType[e.type];
        
this.moved        false;
        
this.distX        0;
        
this.distY        0;
        
this.directionX 0;
        
this.directionY 0;
        
this.directionLocked 0;

        
this._transitionTime();

        
this.startTime utils.getTime();

        if ( 
this.options.useTransition && this.isInTransition ) {
            
this.isInTransition false;
            
pos this.getComputedPosition();
            
this._translate(Math.round(pos.x), Math.round(pos.y));
            
this._execEvent('scrollEnd');
        } else if ( !
this.options.useTransition && this.isAnimating ) {
            
this.isAnimating false;
            
this._execEvent('scrollEnd');
        }

        
this.startX    this.x;
        
this.startY    this.y;
        
this.absStartX this.x;
        
this.absStartY this.y;
        
this.pointX    point.pageX;
        
this.pointY    point.pageY;

        
this._execEvent('beforeScrollStart');
    },

    
_move: function (e) {
        if ( !
this.enabled || utils.eventType[e.type] !== this.initiated ) {
            return;
        }

        if ( 
this.options.preventDefault ) {    // increases performance on Android? TODO: check!
            
e.preventDefault();
        }

        var 
point        e.touches e.touches[0] : e,
            
deltaX        point.pageX this.pointX,
            
deltaY        point.pageY this.pointY,
            
timestamp    utils.getTime(),
            
newXnewY,
            
absDistXabsDistY;

        
this.pointX        point.pageX;
        
this.pointY        point.pageY;

        
this.distX        += deltaX;
        
this.distY        += deltaY;
        
absDistX        Math.abs(this.distX);
        
absDistY        Math.abs(this.distY);

        
// We need to move at least 10 pixels for the scrolling to initiate
        
if ( timestamp this.endTime 300 && (absDistX 10 && absDistY 10) ) {
            return;
        }

        
// If you are scrolling in one direction lock the other
        
if ( !this.directionLocked && !this.options.freeScroll ) {
            if ( 
absDistX absDistY this.options.directionLockThreshold ) {
                
this.directionLocked 'h';        // lock horizontally
            
} else if ( absDistY >= absDistX this.options.directionLockThreshold ) {
                
this.directionLocked 'v';        // lock vertically
            
} else {
                
this.directionLocked 'n';        // no lock
            
}
        }

        if ( 
this.directionLocked == 'h' ) {
            if ( 
this.options.eventPassthrough == 'vertical' ) {
                
e.preventDefault();
            } else if ( 
this.options.eventPassthrough == 'horizontal' ) {
                
this.initiated false;
                return;
            }

            
deltaY 0;
        } else if ( 
this.directionLocked == 'v' ) {
            if ( 
this.options.eventPassthrough == 'horizontal' ) {
                
e.preventDefault();
            } else if ( 
this.options.eventPassthrough == 'vertical' ) {
                
this.initiated false;
                return;
            }

            
deltaX 0;
        }

        
deltaX this.hasHorizontalScroll deltaX 0;
        
deltaY this.hasVerticalScroll deltaY 0;

        
newX this.deltaX;
        
newY this.deltaY;

        
// Slow down if outside of the boundaries
        
if ( newX || newX this.maxScrollX ) {
            
newX this.options.bounce this.deltaX newX this.maxScrollX;
        }
        if ( 
newY || newY this.maxScrollY ) {
            
newY this.options.bounce this.deltaY newY this.maxScrollY;
        }

        
this.directionX deltaX ? -deltaX 0;
        
this.directionY deltaY ? -deltaY 0;

        if ( !
this.moved ) {
            
this._execEvent('scrollStart');
        }

        
this.moved true;

        
this._translate(newXnewY);

/* REPLACE START: _move */

        
if ( timestamp this.startTime 300 ) {
            
this.startTime timestamp;
            
this.startX this.x;
            
this.startY this.y;
        }

/* REPLACE END: _move */

    
},

    
_end: function (e) {
        if ( !
this.enabled || utils.eventType[e.type] !== this.initiated ) {
            return;
        }

        if ( 
this.options.preventDefault && !utils.preventDefaultException(e.targetthis.options.preventDefaultException) ) {
            
e.preventDefault();
        }

        var 
point e.changedTouches e.changedTouches[0] : e,
            
momentumX,
            
momentumY,
            
duration utils.getTime() - this.startTime,
            
newX Math.round(this.x),
            
newY Math.round(this.y),
            
distanceX Math.abs(newX this.startX),
            
distanceY Math.abs(newY this.startY),
            
time 0,
            
easing '';

        
this.isInTransition 0;
        
this.initiated 0;
        
this.endTime utils.getTime();

        
// reset if we are outside of the boundaries
        
if ( this.resetPosition(this.options.bounceTime) ) {
            return;
        }

        
this.scrollTo(newXnewY);    // ensures that the last position is rounded

        // we scrolled less than 10 pixels
        
if ( !this.moved ) {
            if ( 
this.options.tap ) {
                
utils.tap(ethis.options.tap);
            }

            if ( 
this.options.click ) {
                
utils.click(e);
            }

            
this._execEvent('scrollCancel');
            return;
        }

        if ( 
this._events.flick && duration 200 && distanceX 100 && distanceY 100 ) {
            
this._execEvent('flick');
            return;
        }

        
// start momentum animation if needed
        
if ( this.options.momentum && duration 300 ) {
            
momentumX this.hasHorizontalScroll utils.momentum(this.xthis.startXdurationthis.maxScrollXthis.options.bounce this.wrapperWidth 0this.options.deceleration) : { destinationnewXduration};
            
momentumY this.hasVerticalScroll utils.momentum(this.ythis.startYdurationthis.maxScrollYthis.options.bounce this.wrapperHeight 0this.options.deceleration) : { destinationnewYduration};
            
newX momentumX.destination;
            
newY momentumY.destination;
            
time Math.max(momentumX.durationmomentumY.duration);
            
this.isInTransition 1;
        }


        if ( 
this.options.snap ) {
            var 
snap this._nearestSnap(newXnewY);
            
this.currentPage snap;
            
time this.options.snapSpeed || Math.max(
                    
Math.max(
                        
Math.min(Math.abs(newX snap.x), 1000),
                        
Math.min(Math.abs(newY snap.y), 1000)
                    ), 
300);
            
newX snap.x;
            
newY snap.y;

            
this.directionX 0;
            
this.directionY 0;
            
easing this.options.bounceEasing;
        }

// INSERT POINT: _end

        
if ( newX != this.|| newY != this.) {
            
// change easing function when scroller goes out of the boundaries
            
if ( newX || newX this.maxScrollX || newY || newY this.maxScrollY ) {
                
easing utils.ease.quadratic;
            }

            
this.scrollTo(newXnewYtimeeasing);
            return;
        }

        
this._execEvent('scrollEnd');
    },

    
_resize: function () {
        var 
that this;

        
clearTimeout(this.resizeTimeout);

        
this.resizeTimeout setTimeout(function () {
            
that.refresh();
        }, 
this.options.resizePolling);
    },

    
resetPosition: function (time) {
        var 
this.x,
            
this.y;

        
time time || 0;

        if ( !
this.hasHorizontalScroll || this.) {
            
0;
        } else if ( 
this.this.maxScrollX ) {
            
this.maxScrollX;
        }

        if ( !
this.hasVerticalScroll || this.) {
            
0;
        } else if ( 
this.this.maxScrollY ) {
            
this.maxScrollY;
        }

        if ( 
== this.&& == this.) {
            return 
false;
        }

        
this.scrollTo(xytimethis.options.bounceEasing);

        return 
true;
    },

    
disable: function () {
        
this.enabled false;
    },

    
enable: function () {
        
this.enabled true;
    },

    
refresh: function () {
        var 
rf this.wrapper.offsetHeight;        // Force reflow

        
this.wrapperWidth    this.wrapper.clientWidth;
        
this.wrapperHeight    this.wrapper.clientHeight;

/* REPLACE START: refresh */

        
this.scrollerWidth    this.scroller.offsetWidth;
        
this.scrollerHeight    this.scroller.offsetHeight;

        
this.maxScrollX        this.wrapperWidth this.scrollerWidth;
        
this.maxScrollY        this.wrapperHeight this.scrollerHeight;

/* REPLACE END: refresh */

        
this.hasHorizontalScroll    this.options.scrollX && this.maxScrollX 0;
        
this.hasVerticalScroll        this.options.scrollY && this.maxScrollY 0;

        if ( !
this.hasHorizontalScroll ) {
            
this.maxScrollX 0;
            
this.scrollerWidth this.wrapperWidth;
        }

        if ( !
this.hasVerticalScroll ) {
            
this.maxScrollY 0;
            
this.scrollerHeight this.wrapperHeight;
        }

        
this.endTime 0;
        
this.directionX 0;
        
this.directionY 0;

        
this.wrapperOffset utils.offset(this.wrapper);

        
this._execEvent('refresh');

        
this.resetPosition();

// INSERT POINT: _refresh

    
},

    
on: function (type, fn) {
        if ( !
this._events[type] ) {
            
this._events[type] = [];
        }

        
this._events[type].push(fn);
    },

    
off: function (type, fn) {
        if ( !
this._events[type] ) {
            return;
        }

        var 
index this._events[type].indexOf(fn);

        if ( 
index > -) {
            
this._events[type].splice(index1);
        }
    },

    
_execEvent: function (type) {
        if ( !
this._events[type] ) {
            return;
        }

        var 
0,
            
this._events[type].length;

        if ( !
) {
            return;
        }

        for ( ; 
li++ ) {
            
this._events[type][i].apply(this, [].slice.call(arguments1));
        }
    },

    
scrollBy: function (xytimeeasing) {
        
this.x;
        
this.y;
        
time time || 0;

        
this.scrollTo(xytimeeasing);
    },

    
scrollTo: function (xytimeeasing) {
        
easing easing || utils.ease.circular;

        
this.isInTransition this.options.useTransition && time 0;

        if ( !
time || (this.options.useTransition && easing.style) ) {
            
this._transitionTimingFunction(easing.style);
            
this._transitionTime(time);
            
this._translate(xy);
        } else {
            
this._animate(xytimeeasing.fn);
        }
    },

    
scrollToElement: function (eltimeoffsetXoffsetYeasing) {
        
el el.nodeType el this.scroller.querySelector(el);

        if ( !
el ) {
            return;
        }

        var 
pos utils.offset(el);

        
pos.left -= this.wrapperOffset.left;
        
pos.top  -= this.wrapperOffset.top;

        
// if offsetX/Y are true we center the element to the screen
        
if ( offsetX === true ) {
            
offsetX Math.round(el.offsetWidth this.wrapper.offsetWidth 2);
        }
        if ( 
offsetY === true ) {
            
offsetY Math.round(el.offsetHeight this.wrapper.offsetHeight 2);
        }

        
pos.left -= offsetX || 0;
        
pos.top  -= offsetY || 0;

        
pos.left pos.left pos.left this.maxScrollX this.maxScrollX pos.left;
        
pos.top  pos.top  pos.top  this.maxScrollY this.maxScrollY pos.top;

        
time time === undefined || time === null || time === 'auto' Math.max(Math.abs(this.x-pos.left), Math.abs(this.y-pos.top)) : time;

        
this.scrollTo(pos.leftpos.toptimeeasing);
    },

    
_transitionTime: function (time) {
        
time time || 0;

        
this.scrollerStyle[utils.style.transitionDuration] = time 'ms';

        if ( !
time && utils.isBadAndroid ) {
            
this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
        }


        if ( 
this.indicators ) {
            for ( var 
this.indicators.lengthi--; ) {
                
this.indicators[i].transitionTime(time);
            }
        }


// INSERT POINT: _transitionTime

    
},

    
_transitionTimingFunction: function (easing) {
        
this.scrollerStyle[utils.style.transitionTimingFunction] = easing;


        if ( 
this.indicators ) {
            for ( var 
this.indicators.lengthi--; ) {
                
this.indicators[i].transitionTimingFunction(easing);
            }
        }


// INSERT POINT: _transitionTimingFunction

    
},

    
_translate: function (xy) {
        if ( 
this.options.useTransform ) {

/* REPLACE START: _translate */

            
this.scrollerStyle[utils.style.transform] = 'translate(' 'px,' 'px)' this.translateZ;

/* REPLACE END: _translate */

        
} else {
            
Math.round(x);
            
Math.round(y);
            
this.scrollerStyle.left 'px';
            
this.scrollerStyle.top 'px';
        }

        
this.x;
        
this.y;


    if ( 
this.indicators ) {
        for ( var 
this.indicators.lengthi--; ) {
            
this.indicators[i].updatePosition();
        }
    }


// INSERT POINT: _translate

    
},

    
_initEvents: function (remove) {
        var 
eventType remove utils.removeEvent utils.addEvent,
            
target this.options.bindToWrapper this.wrapper window;

        
eventType(window'orientationchange'this);
        
eventType(window'resize'this);

        if ( 
this.options.click ) {
            
eventType(this.wrapper'click'thistrue);
        }

        if ( !
this.options.disableMouse ) {
            
eventType(this.wrapper'mousedown'this);
            
eventType(target'mousemove'this);
            
eventType(target'mousecancel'this);
            
eventType(target'mouseup'this);
        }

        if ( 
utils.hasPointer && !this.options.disablePointer ) {
            
eventType(this.wrapper'MSPointerDown'this);
            
eventType(target'MSPointerMove'this);
            
eventType(target'MSPointerCancel'this);
            
eventType(target'MSPointerUp'this);
        }

        if ( 
utils.hasTouch && !this.options.disableTouch ) {
            
eventType(this.wrapper'touchstart'this);
            
eventType(target'touchmove'this);
            
eventType(target'touchcancel'this);
            
eventType(target'touchend'this);
        }

        
eventType(this.scroller'transitionend'this);
        
eventType(this.scroller'webkitTransitionEnd'this);
        
eventType(this.scroller'oTransitionEnd'this);
        
eventType(this.scroller'MSTransitionEnd'this);
    },

    
getComputedPosition: function () {
        var 
matrix window.getComputedStyle(this.scrollernull),
            
xy;

        if ( 
this.options.useTransform ) {
            
matrix matrix[utils.style.transform].split(')')[0].split(', ');
            
= +(matrix[12] || matrix[4]);
            
= +(matrix[13] || matrix[5]);
        } else {
            
= +matrix.left.replace(/[^-d.]/g'');
            
= +matrix.top.replace(/[^-d.]/g'');
        }

        return { 
xxy};
    },

    
_initIndicators: function () {
        var 
interactive this.options.interactiveScrollbars,
            
customStyle typeof this.options.scrollbars != 'string',
            
indicators = [],
            
indicator;

        var 
that this;

        
this.indicators = [];

        if ( 
this.options.scrollbars ) {
            
// Vertical scrollbar
            
if ( this.options.scrollY ) {
                
indicator = {
                    
elcreateDefaultScrollbar('v'interactivethis.options.scrollbars),
                    
interactiveinteractive,
                    
defaultScrollbarstrue,
                    
customStylecustomStyle,
                    
resizethis.options.resizeScrollbars,
                    
shrinkthis.options.shrinkScrollbars,
                    
fadethis.options.fadeScrollbars,
                    
listenXfalse
                
};

                
this.wrapper.appendChild(indicator.el);
                
indicators.push(indicator);
            }

            
// Horizontal scrollbar
            
if ( this.options.scrollX ) {
                
indicator = {
                    
elcreateDefaultScrollbar('h'interactivethis.options.scrollbars),
                    
interactiveinteractive,
                    
defaultScrollbarstrue,
                    
customStylecustomStyle,
                    
resizethis.options.resizeScrollbars,
                    
shrinkthis.options.shrinkScrollbars,
                    
fadethis.options.fadeScrollbars,
                    
listenYfalse
                
};

                
this.wrapper.appendChild(indicator.el);
                
indicators.push(indicator);
            }
        }

        if ( 
this.options.indicators ) {
            
// TODO: check concat compatibility
            
indicators indicators.concat(this.options.indicators);
        }

        for ( var 
indicators.lengthi--; ) {
            
this.indicators.push( new Indicator(thisindicators[i]) );
        }

        
// TODO: check if we can use array.map (wide compatibility and performance issues)
        
function _indicatorsMap (fn) {
            for ( var 
that.indicators.lengthi--; ) {
                fn.
call(that.indicators[i]);
            }
        }

        if ( 
this.options.fadeScrollbars ) {
            
this.on('scrollEnd', function () {
                
_indicatorsMap(function () {
                    
this.fade();
                });
            });

            
this.on('scrollCancel', function () {
                
_indicatorsMap(function () {
                    
this.fade();
                });
            });

            
this.on('scrollStart', function () {
                
_indicatorsMap(function () {
                    
this.fade(1);
                });
            });

            
this.on('beforeScrollStart', function () {
                
_indicatorsMap(function () {
                    
this.fade(1true);
                });
            });
        }


        
this.on('refresh', function () {
            
_indicatorsMap(function () {
                
this.refresh();
            });
        });

        
this.on('destroy', function () {
            
_indicatorsMap(function () {
                
this.destroy();
            });

            
delete this.indicators;
        });
    },

    
_initWheel: function () {
        
utils.addEvent(this.wrapper'wheel'this);
        
utils.addEvent(this.wrapper'mousewheel'this);
        
utils.addEvent(this.wrapper'DOMMouseScroll'this);

        
this.on('destroy', function () {
            
utils.removeEvent(this.wrapper'wheel'this);
            
utils.removeEvent(this.wrapper'mousewheel'this);
            
utils.removeEvent(this.wrapper'DOMMouseScroll'this);
        });
    },

    
_wheel: function (e) {
        if ( !
this.enabled ) {
            return;
        }

        
e.preventDefault();
        
e.stopPropagation();

        var 
wheelDeltaXwheelDeltaY,
            
newXnewY,
            
that this;

        if ( 
this.wheelTimeout === undefined ) {
            
that._execEvent('scrollStart');
        }

        
// Execute the scrollEnd event after 400ms the wheel stopped scrolling
        
clearTimeout(this.wheelTimeout);
        
this.wheelTimeout setTimeout(function () {
            
that._execEvent('scrollEnd');
            
that.wheelTimeout undefined;
        }, 
400);

        if ( 
'deltaX' in e ) {
            
wheelDeltaX = -e.deltaX;
            
wheelDeltaY = -e.deltaY;
        } else if ( 
'wheelDeltaX' in e ) {
            
wheelDeltaX e.wheelDeltaX 120 this.options.mouseWheelSpeed;
            
wheelDeltaY e.wheelDeltaY 120 this.options.mouseWheelSpeed;
        } else if ( 
'wheelDelta' in e ) {
            
wheelDeltaX wheelDeltaY e.wheelDelta 120 this.options.mouseWheelSpeed;
        } else if ( 
'detail' in e ) {
            
wheelDeltaX wheelDeltaY = -e.detail this.options.mouseWheelSpeed;
        } else {
            return;
        }

        
wheelDeltaX *= this.options.invertWheelDirection;
        
wheelDeltaY *= this.options.invertWheelDirection;

        if ( !
this.hasVerticalScroll ) {
            
wheelDeltaX wheelDeltaY;
            
wheelDeltaY 0;
        }

        if ( 
this.options.snap ) {
            
newX this.currentPage.pageX;
            
newY this.currentPage.pageY;

            if ( 
wheelDeltaX ) {
                
newX--;
            } else if ( 
wheelDeltaX ) {
                
newX++;
            }

            if ( 
wheelDeltaY ) {
                
newY--;
            } else if ( 
wheelDeltaY ) {
                
newY++;
            }

            
this.goToPage(newXnewY);

            return;
        }

        
newX this.Math.round(this.hasHorizontalScroll wheelDeltaX 0);
        
newY this.Math.round(this.hasVerticalScroll wheelDeltaY 0);

        if ( 
newX ) {
            
newX 0;
        } else if ( 
newX this.maxScrollX ) {
            
newX this.maxScrollX;
        }

        if ( 
newY ) {
            
newY 0;
        } else if ( 
newY this.maxScrollY ) {
            
newY this.maxScrollY;
        }

        
this.scrollTo(newXnewY0);

// INSERT POINT: _wheel
    
},

    
_initSnap: function () {
        
this.currentPage = {};

        if ( 
typeof this.options.snap == 'string' ) {
            
this.options.snap this.scroller.querySelectorAll(this.options.snap);
        }

        
this.on('refresh', function () {
            var 
0l,
                
0n,
                
cxcy,
                
0y,
                
stepX this.options.snapStepX || this.wrapperWidth,
                
stepY this.options.snapStepY || this.wrapperHeight,
                
el;

            
this.pages = [];

            if ( !
this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight ) {
                return;
            }

            if ( 
this.options.snap === true ) {
                
cx Math.roundstepX );
                
cy Math.roundstepY );

                while ( 
> -this.scrollerWidth ) {
                    
this.pages[i] = [];
                    
0;
                    
0;

                    while ( 
> -this.scrollerHeight ) {
                        
this.pages[i][l] = {
                            
xMath.max(xthis.maxScrollX),
                            
yMath.max(ythis.maxScrollY),
                            
widthstepX,
                            
heightstepY,
                            
cxcx,
                            
cycy
                        
};

                        
-= stepY;
                        
l++;
                    }

                    
-= stepX;
                    
i++;
                }
            } else {
                
el this.options.snap;
                
el.length;
                
= -1;

                for ( ; 
li++ ) {
                    if ( 
=== || el[i].offsetLeft <= el[i-1].offsetLeft ) {
                        
0;
                        
n++;
                    }

                    if ( !
this.pages[m] ) {
                        
this.pages[m] = [];
                    }

                    
Math.max(-el[i].offsetLeftthis.maxScrollX);
                    
Math.max(-el[i].offsetTopthis.maxScrollY);
                    
cx Math.round(el[i].offsetWidth 2);
                    
cy Math.round(el[i].offsetHeight 2);

                    
this.pages[m][n] = {
                        
xx,
                        
yy,
                        
widthel[i].offsetWidth,
                        
heightel[i].offsetHeight,
                        
cxcx,
                        
cycy
                    
};

                    if ( 
this.maxScrollX ) {
                        
m++;
                    }
                }
            }

            
this.goToPage(this.currentPage.pageX || 0this.currentPage.pageY || 00);

            
// Update snap threshold if needed
            
if ( this.options.snapThreshold === ) {
                
this.snapThresholdX this.options.snapThreshold;
                
this.snapThresholdY this.options.snapThreshold;
            } else {
                
this.snapThresholdX Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width this.options.snapThreshold);
                
this.snapThresholdY Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height this.options.snapThreshold);
            }
        });

        
this.on('flick', function () {
            var 
time this.options.snapSpeed || Math.max(
                    
Math.max(
                        
Math.min(Math.abs(this.this.startX), 1000),
                        
Math.min(Math.abs(this.this.startY), 1000)
                    ), 
300);

            
this.goToPage(
                
this.currentPage.pageX this.directionX,
                
this.currentPage.pageY this.directionY,
                
time
            
);
        });
    },

    
_nearestSnap: function (xy) {
        if ( !
this.pages.length ) {
            return { 
x0y0pageX0pageY};
        }

        var 
0,
            
this.pages.length,
            
0;

        
// Check if we exceeded the snap threshold
        
if ( Math.abs(this.absStartX) < this.snapThresholdX &&
            
Math.abs(this.absStartY) < this.snapThresholdY ) {
            return 
this.currentPage;
        }

        if ( 
) {
            
0;
        } else if ( 
this.maxScrollX ) {
            
this.maxScrollX;
        }

        if ( 
) {
            
0;
        } else if ( 
this.maxScrollY ) {
            
this.maxScrollY;
        }

        for ( ; 
li++ ) {
            if ( 
>= this.pages[i][0].cx ) {
                
this.pages[i][0].x;
                break;
            }
        }

        
this.pages[i].length;

        for ( ; 
lm++ ) {
            if ( 
>= this.pages[0][m].cy ) {
                
this.pages[0][m].y;
                break;
            }
        }

        if ( 
== this.currentPage.pageX ) {
            
+= this.directionX;

            if ( 
) {
                
0;
            } else if ( 
>= this.pages.length ) {
                
this.pages.length 1;
            }

            
this.pages[i][0].x;
        }

        if ( 
== this.currentPage.pageY ) {
            
+= this.directionY;

            if ( 
) {
                
0;
            } else if ( 
>= this.pages[0].length ) {
                
this.pages[0].length 1;
            }

            
this.pages[0][m].y;
        }

        return {
            
xx,
            
yy,
            
pageXi,
            
pageYm
        
};
    },

    
goToPage: function (xytimeeasing) {
        
easing easing || this.options.bounceEasing;

        if ( 
>= this.pages.length ) {
            
this.pages.length 1;
        } else if ( 
) {
            
0;
        }

        if ( 
>= this.pages[x].length ) {
            
this.pages[x].length 1;
        } else if ( 
) {
            
0;
        }

        var 
posX this.pages[x][y].x,
            
posY this.pages[x][y].y;

        
time time === undefined this.options.snapSpeed || Math.max(
            
Math.max(
                
Math.min(Math.abs(posX this.x), 1000),
                
Math.min(Math.abs(posY this.y), 1000)
            ), 
300) : time;

        
this.currentPage = {
            
xposX,
            
yposY,
            
pageXx,
            
pageYy
        
};

        
this.scrollTo(posXposYtimeeasing);
    },

    
next: function (timeeasing) {
        var 
this.currentPage.pageX,
            
this.currentPage.pageY;

        
x++;

        if ( 
>= this.pages.length && this.hasVerticalScroll ) {
            
0;
            
y++;
        }

        
this.goToPage(xytimeeasing);
    },

    
prev: function (timeeasing) {
        var 
this.currentPage.pageX,
            
this.currentPage.pageY;

        
x--;

        if ( 
&& this.hasVerticalScroll ) {
            
0;
            
y--;
        }

        
this.goToPage(xytimeeasing);
    },

    
_initKeys: function (e) {
        
// default key bindings
        
var keys = {
            
pageUp33,
            
pageDown34,
            
end35,
            
home36,
            
left37,
            
up38,
            
right39,
            
down40
        
};
        var 
i;

        
// if you give me characters I give you keycode
        
if ( typeof this.options.keyBindings == 'object' ) {
            for ( 
i in this.options.keyBindings ) {
                if ( 
typeof this.options.keyBindings[i] == 'string' ) {
                    
this.options.keyBindings[i] = this.options.keyBindings[i].toUpperCase().charCodeAt(0);
                }
            }
        } else {
            
this.options.keyBindings = {};
        }

        for ( 
i in keys ) {
            
this.options.keyBindings[i] = this.options.keyBindings[i] || keys[i];
        }

        
utils.addEvent(window'keydown'this);

        
this.on('destroy', function () {
            
utils.removeEvent(window'keydown'this);
        });
    },

    
_key: function (e) {
        if ( !
this.enabled ) {
            return;
        }

        var 
snap this.options.snap,    // we are using this alot, better to cache it
            
newX snap this.currentPage.pageX this.x,
            
newY snap this.currentPage.pageY this.y,
            
now utils.getTime(),
            
prevTime this.keyTime || 0,
            
acceleration 0.250,
            
pos;

        if ( 
this.options.useTransition && this.isInTransition ) {
            
pos this.getComputedPosition();

            
this._translate(Math.round(pos.x), Math.round(pos.y));
            
this.isInTransition false;
        }

        
this.keyAcceleration now prevTime 200 Math.min(this.keyAcceleration acceleration50) : 0;

        switch ( 
e.keyCode ) {
            case 
this.options.keyBindings.pageUp:
                if ( 
this.hasHorizontalScroll && !this.hasVerticalScroll ) {
                    
newX += snap this.wrapperWidth;
                } else {
                    
newY += snap this.wrapperHeight;
                }
                break;
            case 
this.options.keyBindings.pageDown:
                if ( 
this.hasHorizontalScroll && !this.hasVerticalScroll ) {
                    
newX -= snap this.wrapperWidth;
                } else {
                    
newY -= snap this.wrapperHeight;
                }
                break;
            case 
this.options.keyBindings.end:
                
newX snap this.pages.length-this.maxScrollX;
                
newY snap this.pages[0].length-this.maxScrollY;
                break;
            case 
this.options.keyBindings.home:
                
newX 0;
                
newY 0;
                break;
            case 
this.options.keyBindings.left:
                
newX += snap ? -this.keyAcceleration>>0;
                break;
            case 
this.options.keyBindings.up:
                
newY += snap this.keyAcceleration>>0;
                break;
            case 
this.options.keyBindings.right:
                
newX -= snap ? -this.keyAcceleration>>0;
                break;
            case 
this.options.keyBindings.down:
                
newY -= snap this.keyAcceleration>>0;
                break;
            default:
                return;
        }

        if ( 
snap ) {
            
this.goToPage(newXnewY);
            return;
        }

        if ( 
newX ) {
            
newX 0;
            
this.keyAcceleration 0;
        } else if ( 
newX this.maxScrollX ) {
            
newX this.maxScrollX;
            
this.keyAcceleration 0;
        }

        if ( 
newY ) {
            
newY 0;
            
this.keyAcceleration 0;
        } else if ( 
newY this.maxScrollY ) {
            
newY this.maxScrollY;
            
this.keyAcceleration 0;
        }

        
this.scrollTo(newXnewY0);

        
this.keyTime now;
    },

    
_animate: function (destXdestYdurationeasingFn) {
        var 
that this,
            
startX this.x,
            
startY this.y,
            
startTime utils.getTime(),
            
destTime startTime duration;

        function 
step () {
            var 
now utils.getTime(),
                
newXnewY,
                
easing;

            if ( 
now >= destTime ) {
                
that.isAnimating false;
                
that._translate(destXdestY);

                if ( !
that.resetPosition(that.options.bounceTime) ) {
                    
that._execEvent('scrollEnd');
                }

                return;
            }

            
now = ( now startTime ) / duration;
            
easing easingFn(now);
            
newX = ( destX startX ) * easing startX;
            
newY = ( destY startY ) * easing startY;
            
that._translate(newXnewY);

            if ( 
that.isAnimating ) {
                
rAF(step);
            }
        }

        
this.isAnimating true;
        
step();
    },
    
handleEvent: function (e) {
        switch ( 
e.type ) {
            case 
'touchstart':
            case 
'MSPointerDown':
            case 
'mousedown':
                
this._start(e);
                break;
            case 
'touchmove':
            case 
'MSPointerMove':
            case 
'mousemove':
                
this._move(e);
                break;
            case 
'touchend':
            case 
'MSPointerUp':
            case 
'mouseup':
            case 
'touchcancel':
            case 
'MSPointerCancel':
            case 
'mousecancel':
                
this._end(e);
                break;
            case 
'orientationchange':
            case 
'resize':
                
this._resize();
                break;
            case 
'transitionend':
            case 
'webkitTransitionEnd':
            case 
'oTransitionEnd':
            case 
'MSTransitionEnd':
                
this._transitionEnd(e);
                break;
            case 
'wheel':
            case 
'DOMMouseScroll':
            case 
'mousewheel':
                
this._wheel(e);
                break;
            case 
'keydown':
                
this._key(e);
                break;
            case 
'click':
                if ( !
e._constructed ) {
                    
e.preventDefault();
                    
e.stopPropagation();
                }
                break;
        }
    }
};
function 
createDefaultScrollbar (directioninteractivetype) {
    var 
scrollbar document.createElement('div'),
        
indicator document.createElement('div');

    if ( 
type === true ) {
        
scrollbar.style.cssText 'position:absolute;z-index:9999';
        
indicator.style.cssText '-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px';
    }

    
indicator.className 'iScrollIndicator';

    if ( 
direction == 'h' ) {
        if ( 
type === true ) {
            
scrollbar.style.cssText += ';height:7px;left:2px;right:2px;bottom:0';
            
indicator.style.height '100%';
        }
        
scrollbar.className 'iScrollHorizontalScrollbar';
    } else {
        if ( 
type === true ) {
            
scrollbar.style.cssText += ';width:7px;bottom:2px;top:2px;right:1px';
            
indicator.style.width '100%';
        }
        
scrollbar.className 'iScrollVerticalScrollbar';
    }

    
scrollbar.style.cssText += ';overflow:hidden';

    if ( !
interactive ) {
        
scrollbar.style.pointerEvents 'none';
    }

    
scrollbar.appendChild(indicator);

    return 
scrollbar;
}

function 
Indicator (scrolleroptions) {
    
this.wrapper typeof options.el == 'string' document.querySelector(options.el) : options.el;
    
this.wrapperStyle this.wrapper.style;
    
this.indicator this.wrapper.children[0];
    
this.indicatorStyle this.indicator.style;
    
this.scroller scroller;

    
this.options = {
        
listenXtrue,
        
listenYtrue,
        
interactivefalse,
        
resizetrue,
        
defaultScrollbarsfalse,
        
shrinkfalse,
        
fadefalse,
        
speedRatioX0,
        
speedRatioY0
    
};

    for ( var 
i in options ) {
        
this.options[i] = options[i];
    }

    
this.sizeRatioX 1;
    
this.sizeRatioY 1;
    
this.maxPosX 0;
    
this.maxPosY 0;

    if ( 
this.options.interactive ) {
        if ( !
this.options.disableTouch ) {
            
utils.addEvent(this.indicator'touchstart'this);
            
utils.addEvent(window'touchend'this);
        }
        if ( !
this.options.disablePointer ) {
            
utils.addEvent(this.indicator'MSPointerDown'this);
            
utils.addEvent(window'MSPointerUp'this);
        }
        if ( !
this.options.disableMouse ) {
            
utils.addEvent(this.indicator'mousedown'this);
            
utils.addEvent(window'mouseup'this);
        }
    }

    if ( 
this.options.fade ) {
        
this.wrapperStyle[utils.style.transform] = this.scroller.translateZ;
        
this.wrapperStyle[utils.style.transitionDuration] = utils.isBadAndroid '0.001s' '0ms';
        
this.wrapperStyle.opacity '0';
    }
}

Indicator.prototype = {
    
handleEvent: function (e) {
        switch ( 
e.type ) {
            case 
'touchstart':
            case 
'MSPointerDown':
            case 
'mousedown':
                
this._start(e);
                break;
            case 
'touchmove':
            case 
'MSPointerMove':
            case 
'mousemove':
                
this._move(e);
                break;
            case 
'touchend':
            case 
'MSPointerUp':
            case 
'mouseup':
            case 
'touchcancel':
            case 
'MSPointerCancel':
            case 
'mousecancel':
                
this._end(e);
                break;
        }
    },

    
destroy: function () {
        if ( 
this.options.interactive ) {
            
utils.removeEvent(this.indicator'touchstart'this);
            
utils.removeEvent(this.indicator'MSPointerDown'this);
            
utils.removeEvent(this.indicator'mousedown'this);

            
utils.removeEvent(window'touchmove'this);
            
utils.removeEvent(window'MSPointerMove'this);
            
utils.removeEvent(window'mousemove'this);

            
utils.removeEvent(window'touchend'this);
            
utils.removeEvent(window'MSPointerUp'this);
            
utils.removeEvent(window'mouseup'this);
        }

        if ( 
this.options.defaultScrollbars ) {
            
this.wrapper.parentNode.removeChild(this.wrapper);
        }
    },

    
_start: function (e) {
        var 
point e.touches e.touches[0] : e;

        
e.preventDefault();
        
e.stopPropagation();

        
this.transitionTime();

        
this.initiated true;
        
this.moved false;
        
this.lastPointX    point.pageX;
        
this.lastPointY    point.pageY;

        
this.startTime    utils.getTime();

        if ( !
this.options.disableTouch ) {
            
utils.addEvent(window'touchmove'this);
        }
        if ( !
this.options.disablePointer ) {
            
utils.addEvent(window'MSPointerMove'this);
        }
        if ( !
this.options.disableMouse ) {
            
utils.addEvent(window'mousemove'this);
        }

        
this.scroller._execEvent('beforeScrollStart');
    },

    
_move: function (e) {
        var 
point e.touches e.touches[0] : e,
            
deltaXdeltaY,
            
newXnewY,
            
timestamp utils.getTime();

        if ( !
this.moved ) {
            
this.scroller._execEvent('scrollStart');
        }

        
this.moved true;

        
deltaX point.pageX this.lastPointX;
        
this.lastPointX point.pageX;

        
deltaY point.pageY this.lastPointY;
        
this.lastPointY point.pageY;

        
newX this.deltaX;
        
newY this.deltaY;

        
this._pos(newXnewY);

// INSERT POINT: indicator._move

        
e.preventDefault();
        
e.stopPropagation();
    },

    
_end: function (e) {
        if ( !
this.initiated ) {
            return;
        }

        
this.initiated false;

        
e.preventDefault();
        
e.stopPropagation();

        
utils.removeEvent(window'touchmove'this);
        
utils.removeEvent(window'MSPointerMove'this);
        
utils.removeEvent(window'mousemove'this);

        if ( 
this.scroller.options.snap ) {
            var 
snap this.scroller._nearestSnap(this.scroller.xthis.scroller.y);

            var 
time this.options.snapSpeed || Math.max(
                    
Math.max(
                        
Math.min(Math.abs(this.scroller.snap.x), 1000),
                        
Math.min(Math.abs(this.scroller.snap.y), 1000)
                    ), 
300);

            if ( 
this.scroller.!= snap.|| this.scroller.!= snap.) {
                
this.scroller.directionX 0;
                
this.scroller.directionY 0;
                
this.scroller.currentPage snap;
                
this.scroller.scrollTo(snap.xsnap.ytimethis.scroller.options.bounceEasing);
            }
        }

        if ( 
this.moved ) {
            
this.scroller._execEvent('scrollEnd');
        }
    },

    
transitionTime: function (time) {
        
time time || 0;
        
this.indicatorStyle[utils.style.transitionDuration] = time 'ms';

        if ( !
time && utils.isBadAndroid ) {
            
this.indicatorStyle[utils.style.transitionDuration] = '0.001s';
        }
    },

    
transitionTimingFunction: function (easing) {
        
this.indicatorStyle[utils.style.transitionTimingFunction] = easing;
    },

    
refresh: function () {
        
this.transitionTime();

        if ( 
this.options.listenX && !this.options.listenY ) {
            
this.indicatorStyle.display this.scroller.hasHorizontalScroll 'block' 'none';
        } else if ( 
this.options.listenY && !this.options.listenX ) {
            
this.indicatorStyle.display this.scroller.hasVerticalScroll 'block' 'none';
        } else {
            
this.indicatorStyle.display this.scroller.hasHorizontalScroll || this.scroller.hasVerticalScroll 'block' 'none';
        }

        if ( 
this.scroller.hasHorizontalScroll && this.scroller.hasVerticalScroll ) {
            
utils.addClass(this.wrapper'iScrollBothScrollbars');
            
utils.removeClass(this.wrapper'iScrollLoneScrollbar');

            if ( 
this.options.defaultScrollbars && this.options.customStyle ) {
                if ( 
this.options.listenX ) {
                    
this.wrapper.style.right '8px';
                } else {
                    
this.wrapper.style.bottom '8px';
                }
            }
        } else {
            
utils.removeClass(this.wrapper'iScrollBothScrollbars');
            
utils.addClass(this.wrapper'iScrollLoneScrollbar');

            if ( 
this.options.defaultScrollbars && this.options.customStyle ) {
                if ( 
this.options.listenX ) {
                    
this.wrapper.style.right '2px';
                } else {
                    
this.wrapper.style.bottom '2px';
                }
            }
        }

        var 
this.wrapper.offsetHeight;    // force refresh

        
if ( this.options.listenX ) {
            
this.wrapperWidth this.wrapper.clientWidth;
            if ( 
this.options.resize ) {
                
this.indicatorWidth Math.max(Math.round(this.wrapperWidth this.wrapperWidth / (this.scroller.scrollerWidth || this.wrapperWidth || 1)), 8);
                
this.indicatorStyle.width this.indicatorWidth 'px';
            } else {
                
this.indicatorWidth this.indicator.clientWidth;
            }

            
this.maxPosX this.wrapperWidth this.indicatorWidth;

            if ( 
this.options.shrink == 'clip' ) {
                
this.minBoundaryX = -this.indicatorWidth 8;
                
this.maxBoundaryX this.wrapperWidth 8;
            } else {
                
this.minBoundaryX 0;
                
this.maxBoundaryX this.maxPosX;
            }

            
this.sizeRatioX this.options.speedRatioX || (this.scroller.maxScrollX && (this.maxPosX this.scroller.maxScrollX));    
        }

        if ( 
this.options.listenY ) {
            
this.wrapperHeight this.wrapper.clientHeight;
            if ( 
this.options.resize ) {
                
this.indicatorHeight Math.max(Math.round(this.wrapperHeight this.wrapperHeight / (this.scroller.scrollerHeight || this.wrapperHeight || 1)), 8);
                
this.indicatorStyle.height this.indicatorHeight 'px';
            } else {
                
this.indicatorHeight this.indicator.clientHeight;
            }

            
this.maxPosY this.wrapperHeight this.indicatorHeight;

            if ( 
this.options.shrink == 'clip' ) {
                
this.minBoundaryY = -this.indicatorHeight 8;
                
this.maxBoundaryY this.wrapperHeight 8;
            } else {
                
this.minBoundaryY 0;
                
this.maxBoundaryY this.maxPosY;
            }

            
this.maxPosY this.wrapperHeight this.indicatorHeight;
            
this.sizeRatioY this.options.speedRatioY || (this.scroller.maxScrollY && (this.maxPosY this.scroller.maxScrollY));
        }

        
this.updatePosition();
    },

    
updatePosition: function () {
        var 
this.options.listenX && Math.round(this.sizeRatioX this.scroller.x) || 0,
            
this.options.listenY && Math.round(this.sizeRatioY this.scroller.y) || 0;

        if ( !
this.options.ignoreBoundaries ) {
            if ( 
this.minBoundaryX ) {
                if ( 
this.options.shrink == 'scale' ) {
                    
this.width Math.max(this.indicatorWidth x8);
                    
this.indicatorStyle.width this.width 'px';
                }
                
this.minBoundaryX;
            } else if ( 
this.maxBoundaryX ) {
                if ( 
this.options.shrink == 'scale' ) {
                    
this.width Math.max(this.indicatorWidth - (this.maxPosX), 8);
                    
this.indicatorStyle.width this.width 'px';
                    
this.maxPosX this.indicatorWidth this.width;
                } else {
                    
this.maxBoundaryX;
                }
            } else if ( 
this.options.shrink == 'scale' && this.width != this.indicatorWidth ) {
                
this.width this.indicatorWidth;
                
this.indicatorStyle.width this.width 'px';
            }

            if ( 
this.minBoundaryY ) {
                if ( 
this.options.shrink == 'scale' ) {
                    
this.height Math.max(this.indicatorHeight 38);
                    
this.indicatorStyle.height this.height 'px';
                }
                
this.minBoundaryY;
            } else if ( 
this.maxBoundaryY ) {
                if ( 
this.options.shrink == 'scale' ) {
                    
this.height Math.max(this.indicatorHeight - (this.maxPosY) * 38);
                    
this.indicatorStyle.height this.height 'px';
                    
this.maxPosY this.indicatorHeight this.height;
                } else {
                    
this.maxBoundaryY;
                }
            } else if ( 
this.options.shrink == 'scale' && this.height != this.indicatorHeight ) {
                
this.height this.indicatorHeight;
                
this.indicatorStyle.height this.height 'px';
            }
        }

        
this.x;
        
this.y;

        if ( 
this.scroller.options.useTransform ) {
            
this.indicatorStyle[utils.style.transform] = 'translate(' 'px,' 'px)' this.scroller.translateZ;
        } else {
            
this.indicatorStyle.left 'px';
            
this.indicatorStyle.top 'px';
        }
    },

    
_pos: function (xy) {
        if ( 
) {
            
0;
        } else if ( 
this.maxPosX ) {
            
this.maxPosX;
        }

        if ( 
) {
            
0;
        } else if ( 
this.maxPosY ) {
            
this.maxPosY;
        }

        
this.options.listenX Math.round(this.sizeRatioX) : this.scroller.x;
        
this.options.listenY Math.round(this.sizeRatioY) : this.scroller.y;

        
this.scroller.scrollTo(xy);
    },

    
fade: function (valhold) {
        if ( 
hold && !this.visible ) {
            return;
        }

        
clearTimeout(this.fadeTimeout);
        
this.fadeTimeout null;

        var 
time val 250 500,
            
delay val 300;

        
val val '1' '0';

        
this.wrapperStyle[utils.style.transitionDuration] = time 'ms';

        
this.fadeTimeout setTimeout((function (val) {
            
this.wrapperStyle.opacity val;
            
this.visible = +val;
        }).
bind(thisval), delay);
    }
};

IScroll.utils utils;

if ( 
typeof module != 'undefined' && module.exports ) {
    
module.exports IScroll;
} else {
    
window.IScroll IScroll;
}

})(
windowdocumentMath);
?>
Онлайн: 1
Реклама