Subversion Repositories SmartDukaan

Rev

Rev 20684 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 20684 Rev 20685
Line 1... Line 1...
1
/*! iScroll v5.2.0-snapshot ~ (c) 2008-2017 Matteo Spinelli ~ http://cubiq.org/license */
1
/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
2
(function (window, document, Math) {
2
(function (window, document, Math) {
3
var rAF = window.requestAnimationFrame	||
3
var rAF = window.requestAnimationFrame	||
4
	window.webkitRequestAnimationFrame	||
4
	window.webkitRequestAnimationFrame	||
5
	window.mozRequestAnimationFrame		||
5
	window.mozRequestAnimationFrame		||
6
	window.oRequestAnimationFrame		||
6
	window.oRequestAnimationFrame		||
Line 46... Line 46...
46
	me.removeEvent = function (el, type, fn, capture) {
46
	me.removeEvent = function (el, type, fn, capture) {
47
		el.removeEventListener(type, fn, !!capture);
47
		el.removeEventListener(type, fn, !!capture);
48
	};
48
	};
49
 
49
 
50
	me.prefixPointerEvent = function (pointerEvent) {
50
	me.prefixPointerEvent = function (pointerEvent) {
51
		return window.MSPointerEvent ?
51
		return window.MSPointerEvent ? 
52
			'MSPointer' + pointerEvent.charAt(7).toUpperCase() + pointerEvent.substr(8):
52
			'MSPointer' + pointerEvent.charAt(9).toUpperCase() + pointerEvent.substr(10):
53
			pointerEvent;
53
			pointerEvent;
54
	};
54
	};
55
 
55
 
56
	me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
56
	me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
57
		var distance = current - start,
57
		var distance = current - start,
Line 84... Line 84...
84
 
84
 
85
	me.extend(me, {
85
	me.extend(me, {
86
		hasTransform: _transform !== false,
86
		hasTransform: _transform !== false,
87
		hasPerspective: _prefixStyle('perspective') in _elementStyle,
87
		hasPerspective: _prefixStyle('perspective') in _elementStyle,
88
		hasTouch: 'ontouchstart' in window,
88
		hasTouch: 'ontouchstart' in window,
89
		hasPointer: !!(window.PointerEvent || window.MSPointerEvent), // IE10 is prefixed
89
		hasPointer: window.PointerEvent || window.MSPointerEvent, // IE10 is prefixed
90
		hasTransition: _prefixStyle('transition') in _elementStyle
90
		hasTransition: _prefixStyle('transition') in _elementStyle
91
	});
91
	});
92
 
92
 
93
	/*
-
 
94
	This should find all Android browsers lower than build 535.19 (both stock browser and webview)
93
	// This should find all Android browsers lower than build 535.19 (both stock browser and webview)
95
	- galaxy S2 is ok
-
 
96
    - 2.3.6 : `AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1`
-
 
97
    - 4.0.4 : `AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30`
-
 
98
   - galaxy S3 is badAndroid (stock brower, webview)
-
 
99
     `AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30`
-
 
100
   - galaxy S4 is badAndroid (stock brower, webview)
-
 
101
     `AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30`
-
 
102
   - galaxy S5 is OK
-
 
103
     `AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36 (Chrome/)`
-
 
104
   - galaxy S6 is OK
-
 
105
     `AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36 (Chrome/)`
-
 
106
  */
-
 
107
	me.isBadAndroid = (function() {
-
 
108
		var appVersion = window.navigator.appVersion;
-
 
109
		// Android browser is not a chrome browser.
-
 
110
		if (/Android/.test(appVersion) && !(/Chrome\/\d/.test(appVersion))) {
94
	me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
111
			var safariVersion = appVersion.match(/Safari\/(\d+.\d)/);
-
 
112
			if(safariVersion && typeof safariVersion === "object" && safariVersion.length >= 2) {
-
 
113
				return parseFloat(safariVersion[1]) < 535.19;
-
 
114
			} else {
-
 
115
				return true;
-
 
116
			}
-
 
117
		} else {
-
 
118
			return false;
-
 
119
		}
-
 
120
	})();
-
 
121
 
95
 
122
	me.extend(me.style = {}, {
96
	me.extend(me.style = {}, {
123
		transform: _transform,
97
		transform: _transform,
124
		transitionTimingFunction: _prefixStyle('transitionTimingFunction'),
98
		transitionTimingFunction: _prefixStyle('transitionTimingFunction'),
125
		transitionDuration: _prefixStyle('transitionDuration'),
99
		transitionDuration: _prefixStyle('transitionDuration'),
126
		transitionDelay: _prefixStyle('transitionDelay'),
100
		transitionDelay: _prefixStyle('transitionDelay'),
127
		transformOrigin: _prefixStyle('transformOrigin'),
101
		transformOrigin: _prefixStyle('transformOrigin')
128
		touchAction: _prefixStyle('touchAction')
-
 
129
	});
102
	});
130
 
103
 
131
	me.hasClass = function (e, c) {
104
	me.hasClass = function (e, c) {
132
		var re = new RegExp("(^|\\s)" + c + "(\\s|$)");
105
		var re = new RegExp("(^|\\s)" + c + "(\\s|$)");
133
		return re.test(e.className);
106
		return re.test(e.className);
Line 256... Line 229...
256
	me.click = function (e) {
229
	me.click = function (e) {
257
		var target = e.target,
230
		var target = e.target,
258
			ev;
231
			ev;
259
 
232
 
260
		if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
233
		if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
261
			// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent
-
 
262
			// initMouseEvent is deprecated.
-
 
263
			ev = document.createEvent(window.MouseEvent ? 'MouseEvents' : 'Event');
234
			ev = document.createEvent('MouseEvents');
264
			ev.initEvent('click', true, true);
235
			ev.initMouseEvent('click', true, true, e.view, 1,
265
			ev.view = e.view || window;
-
 
266
			ev.detail = 1;
-
 
267
			ev.screenX = target.screenX || 0;
-
 
268
			ev.screenY = target.screenY || 0;
236
				target.screenX, target.screenY, target.clientX, target.clientY,
269
			ev.clientX = target.clientX || 0;
-
 
270
			ev.clientY = target.clientY || 0;
-
 
271
			ev.ctrlKey = !!e.ctrlKey;
-
 
272
			ev.altKey = !!e.altKey;
-
 
273
			ev.shiftKey = !!e.shiftKey;
-
 
274
			ev.metaKey = !!e.metaKey;
237
				e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
275
			ev.button = 0;
238
				0, null);
276
			ev.relatedTarget = null;
-
 
-
 
239
 
277
			ev._constructed = true;
240
			ev._constructed = true;
278
			target.dispatchEvent(ev);
241
			target.dispatchEvent(ev);
279
		}
242
		}
280
	};
243
	};
281
 
244
 
282
	me.getTouchAction = function(eventPassthrough, addPinch) {
-
 
283
		var touchAction = 'none';
-
 
284
		if ( eventPassthrough === 'vertical' ) {
-
 
285
			touchAction = 'pan-y';
-
 
286
		} else if (eventPassthrough === 'horizontal' ) {
-
 
287
			touchAction = 'pan-x';
-
 
288
		}
-
 
289
		if (addPinch && touchAction != 'none') {
-
 
290
			// add pinch-zoom support if the browser supports it, but if not (eg. Chrome <55) do nothing
-
 
291
			touchAction += ' pinch-zoom';
-
 
292
		}
-
 
293
		return touchAction;
-
 
294
	};
-
 
295
 
-
 
296
	me.getRect = function(el) {
-
 
297
		if (el instanceof SVGElement) {
-
 
298
			var rect = el.getBoundingClientRect();
-
 
299
			return {
-
 
300
				top : rect.top,
-
 
301
				left : rect.left,
-
 
302
				width : rect.width,
-
 
303
				height : rect.height
-
 
304
			};
-
 
305
		} else {
-
 
306
			return {
-
 
307
				top : el.offsetTop,
-
 
308
				left : el.offsetLeft,
-
 
309
				width : el.offsetWidth,
-
 
310
				height : el.offsetHeight
-
 
311
			};
-
 
312
		}
-
 
313
	};
-
 
314
 
-
 
315
	return me;
245
	return me;
316
})();
246
})();
-
 
247
 
317
function IScroll (el, options) {
248
function IScroll (el, options) {
318
	this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
249
	this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
319
	this.scroller = this.wrapper.children[0];
250
	this.scroller = this.wrapper.children[0];
320
	this.scrollerStyle = this.scroller.style;		// cache style for better performance
251
	this.scrollerStyle = this.scroller.style;		// cache style for better performance
321
 
252
 
Line 325... Line 256...
325
 
256
 
326
		mouseWheelSpeed: 20,
257
		mouseWheelSpeed: 20,
327
 
258
 
328
		snapThreshold: 0.334,
259
		snapThreshold: 0.334,
329
 
260
 
330
// INSERT POINT: OPTIONS
261
// INSERT POINT: OPTIONS 
331
		disablePointer : !utils.hasPointer,
-
 
332
		disableTouch : utils.hasPointer || !utils.hasTouch,
-
 
333
		disableMouse : utils.hasPointer || utils.hasTouch,
-
 
-
 
262
 
334
		startX: 0,
263
		startX: 0,
335
		startY: 0,
264
		startY: 0,
336
		scrollY: true,
265
		scrollY: true,
337
		directionLockThreshold: 5,
266
		directionLockThreshold: 5,
338
		momentum: true,
267
		momentum: true,
Line 344... Line 273...
344
		preventDefault: true,
273
		preventDefault: true,
345
		preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ },
274
		preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ },
346
 
275
 
347
		HWCompositing: true,
276
		HWCompositing: true,
348
		useTransition: true,
277
		useTransition: true,
349
		useTransform: true,
278
		useTransform: true
350
		bindToWrapper: typeof window.onmousedown === "undefined"
-
 
351
	};
279
	};
352
 
280
 
353
	for ( var i in options ) {
281
	for ( var i in options ) {
354
		this.options[i] = options[i];
282
		this.options[i] = options[i];
355
	}
283
	}
Line 377... Line 305...
377
 
305
 
378
	if ( this.options.tap === true ) {
306
	if ( this.options.tap === true ) {
379
		this.options.tap = 'tap';
307
		this.options.tap = 'tap';
380
	}
308
	}
381
 
309
 
382
	// https://github.com/cubiq/iscroll/issues/1029
-
 
383
	if (!this.options.useTransition && !this.options.useTransform) {
-
 
384
		if(!(/relative|absolute/i).test(this.scrollerStyle.position)) {
-
 
385
			this.scrollerStyle.position = "relative";
-
 
386
		}
-
 
387
	}
-
 
388
 
-
 
389
	if ( this.options.shrinkScrollbars == 'scale' ) {
310
	if ( this.options.shrinkScrollbars == 'scale' ) {
390
		this.options.useTransition = false;
311
		this.options.useTransition = false;
391
	}
312
	}
392
 
313
 
393
	this.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1;
314
	this.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1;
394
 
315
 
395
// INSERT POINT: NORMALIZATION
316
// INSERT POINT: NORMALIZATION
396
 
317
 
397
	// Some defaults
318
	// Some defaults	
398
	this.x = 0;
319
	this.x = 0;
399
	this.y = 0;
320
	this.y = 0;
400
	this.directionX = 0;
321
	this.directionX = 0;
401
	this.directionY = 0;
322
	this.directionY = 0;
402
	this._events = {};
323
	this._events = {};
Line 409... Line 330...
409
	this.scrollTo(this.options.startX, this.options.startY);
330
	this.scrollTo(this.options.startX, this.options.startY);
410
	this.enable();
331
	this.enable();
411
}
332
}
412
 
333
 
413
IScroll.prototype = {
334
IScroll.prototype = {
414
	version: '5.2.0-snapshot',
335
	version: '5.1.3',
415
 
336
 
416
	_init: function () {
337
	_init: function () {
417
		this._initEvents();
338
		this._initEvents();
418
 
339
 
419
		if ( this.options.scrollbars || this.options.indicators ) {
340
		if ( this.options.scrollbars || this.options.indicators ) {
Line 436... Line 357...
436
 
357
 
437
	},
358
	},
438
 
359
 
439
	destroy: function () {
360
	destroy: function () {
440
		this._initEvents(true);
361
		this._initEvents(true);
441
		clearTimeout(this.resizeTimeout);
-
 
442
 		this.resizeTimeout = null;
-
 
-
 
362
 
443
		this._execEvent('destroy');
363
		this._execEvent('destroy');
444
	},
364
	},
445
 
365
 
446
	_transitionEnd: function (e) {
366
	_transitionEnd: function (e) {
447
		if ( e.target != this.scroller || !this.isInTransition ) {
367
		if ( e.target != this.scroller || !this.isInTransition ) {
Line 456... Line 376...
456
	},
376
	},
457
 
377
 
458
	_start: function (e) {
378
	_start: function (e) {
459
		// React to left mouse button only
379
		// React to left mouse button only
460
		if ( utils.eventType[e.type] != 1 ) {
380
		if ( utils.eventType[e.type] != 1 ) {
461
		  // for button property
-
 
462
		  // http://unixpapa.com/js/mouse.html
-
 
463
		  var button;
-
 
464
	    if (!e.which) {
-
 
465
	      /* IE case */
-
 
466
	      button = (e.button < 2) ? 0 :
-
 
467
	               ((e.button == 4) ? 1 : 2);
-
 
468
	    } else {
-
 
469
	      /* All others */
-
 
470
	      button = e.button;
-
 
471
	    }
-
 
472
			if ( button !== 0 ) {
381
			if ( e.button !== 0 ) {
473
				return;
382
				return;
474
			}
383
			}
475
		}
384
		}
476
 
385
 
477
		if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) {
386
		if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) {
Line 491... Line 400...
491
		this.distY		= 0;
400
		this.distY		= 0;
492
		this.directionX = 0;
401
		this.directionX = 0;
493
		this.directionY = 0;
402
		this.directionY = 0;
494
		this.directionLocked = 0;
403
		this.directionLocked = 0;
495
 
404
 
-
 
405
		this._transitionTime();
-
 
406
 
496
		this.startTime = utils.getTime();
407
		this.startTime = utils.getTime();
497
 
408
 
498
		if ( this.options.useTransition && this.isInTransition ) {
409
		if ( this.options.useTransition && this.isInTransition ) {
499
			this._transitionTime();
-
 
500
			this.isInTransition = false;
410
			this.isInTransition = false;
501
			pos = this.getComputedPosition();
411
			pos = this.getComputedPosition();
502
			this._translate(Math.round(pos.x), Math.round(pos.y));
412
			this._translate(Math.round(pos.x), Math.round(pos.y));
503
			this._execEvent('scrollEnd');
413
			this._execEvent('scrollEnd');
504
		} else if ( !this.options.useTransition && this.isAnimating ) {
414
		} else if ( !this.options.useTransition && this.isAnimating ) {
Line 749... Line 659...
749
	enable: function () {
659
	enable: function () {
750
		this.enabled = true;
660
		this.enabled = true;
751
	},
661
	},
752
 
662
 
753
	refresh: function () {
663
	refresh: function () {
754
		utils.getRect(this.wrapper);		// Force reflow
664
		var rf = this.wrapper.offsetHeight;		// Force reflow
755
 
665
 
756
		this.wrapperWidth	= this.wrapper.clientWidth;
666
		this.wrapperWidth	= this.wrapper.clientWidth;
757
		this.wrapperHeight	= this.wrapper.clientHeight;
667
		this.wrapperHeight	= this.wrapper.clientHeight;
758
 
668
 
759
		var rect = utils.getRect(this.scroller);
-
 
760
/* REPLACE START: refresh */
669
/* REPLACE START: refresh */
761
 
670
 
762
		this.scrollerWidth	= rect.width;
671
		this.scrollerWidth	= this.scroller.offsetWidth;
763
		this.scrollerHeight	= rect.height;
672
		this.scrollerHeight	= this.scroller.offsetHeight;
764
 
673
 
765
		this.maxScrollX		= this.wrapperWidth - this.scrollerWidth;
674
		this.maxScrollX		= this.wrapperWidth - this.scrollerWidth;
766
		this.maxScrollY		= this.wrapperHeight - this.scrollerHeight;
675
		this.maxScrollY		= this.wrapperHeight - this.scrollerHeight;
767
 
676
 
768
/* REPLACE END: refresh */
677
/* REPLACE END: refresh */
769
 
678
 
770
		this.hasHorizontalScroll	= this.options.scrollX && this.maxScrollX < 0;
679
		this.hasHorizontalScroll	= this.options.scrollX && this.maxScrollX < 0;
771
		this.hasVerticalScroll		= this.options.scrollY && this.maxScrollY < 0;
680
		this.hasVerticalScroll		= this.options.scrollY && this.maxScrollY < 0;
772
		
681
 
773
		if ( !this.hasHorizontalScroll ) {
682
		if ( !this.hasHorizontalScroll ) {
774
			this.maxScrollX = 0;
683
			this.maxScrollX = 0;
775
			this.scrollerWidth = this.wrapperWidth;
684
			this.scrollerWidth = this.wrapperWidth;
776
		}
685
		}
777
 
686
 
Line 781... Line 690...
781
		}
690
		}
782
 
691
 
783
		this.endTime = 0;
692
		this.endTime = 0;
784
		this.directionX = 0;
693
		this.directionX = 0;
785
		this.directionY = 0;
694
		this.directionY = 0;
786
		
-
 
787
		if(utils.hasPointer && !this.options.disablePointer) {
-
 
788
			// The wrapper should have `touchAction` property for using pointerEvent.
-
 
789
			this.wrapper.style[utils.style.touchAction] = utils.getTouchAction(this.options.eventPassthrough, true);
-
 
790
 
695
 
791
			// case. not support 'pinch-zoom'
-
 
792
			// https://github.com/cubiq/iscroll/issues/1118#issuecomment-270057583
-
 
793
			if (!this.wrapper.style[utils.style.touchAction]) {
-
 
794
				this.wrapper.style[utils.style.touchAction] = utils.getTouchAction(this.options.eventPassthrough, false);
-
 
795
			}
-
 
796
		}
-
 
797
		this.wrapperOffset = utils.offset(this.wrapper);
696
		this.wrapperOffset = utils.offset(this.wrapper);
798
 
697
 
799
		this._execEvent('refresh');
698
		this._execEvent('refresh');
800
 
699
 
801
		this.resetPosition();
700
		this.resetPosition();
802
 
701
 
803
// INSERT POINT: _refresh
702
// INSERT POINT: _refresh
804
 
703
 
805
	},	
704
	},
806
 
705
 
807
	on: function (type, fn) {
706
	on: function (type, fn) {
808
		if ( !this._events[type] ) {
707
		if ( !this._events[type] ) {
809
			this._events[type] = [];
708
			this._events[type] = [];
810
		}
709
		}
Line 851... Line 750...
851
 
750
 
852
	scrollTo: function (x, y, time, easing) {
751
	scrollTo: function (x, y, time, easing) {
853
		easing = easing || utils.ease.circular;
752
		easing = easing || utils.ease.circular;
854
 
753
 
855
		this.isInTransition = this.options.useTransition && time > 0;
754
		this.isInTransition = this.options.useTransition && time > 0;
-
 
755
 
856
		var transitionType = this.options.useTransition && easing.style;
756
		if ( !time || (this.options.useTransition && easing.style) ) {
857
		if ( !time || transitionType ) {
-
 
858
				if(transitionType) {
-
 
859
					this._transitionTimingFunction(easing.style);
757
			this._transitionTimingFunction(easing.style);
860
					this._transitionTime(time);
758
			this._transitionTime(time);
861
				}
-
 
862
			this._translate(x, y);
759
			this._translate(x, y);
863
		} else {
760
		} else {
864
			this._animate(x, y, time, easing.fn);
761
			this._animate(x, y, time, easing.fn);
865
		}
762
		}
866
	},
763
	},
Line 876... Line 773...
876
 
773
 
877
		pos.left -= this.wrapperOffset.left;
774
		pos.left -= this.wrapperOffset.left;
878
		pos.top  -= this.wrapperOffset.top;
775
		pos.top  -= this.wrapperOffset.top;
879
 
776
 
880
		// if offsetX/Y are true we center the element to the screen
777
		// if offsetX/Y are true we center the element to the screen
881
		var elRect = utils.getRect(el);
-
 
882
		var wrapperRect = utils.getRect(this.wrapper);
-
 
883
		if ( offsetX === true ) {
778
		if ( offsetX === true ) {
884
			offsetX = Math.round(elRect.width / 2 - wrapperRect.width / 2);
779
			offsetX = Math.round(el.offsetWidth / 2 - this.wrapper.offsetWidth / 2);
885
		}
780
		}
886
		if ( offsetY === true ) {
781
		if ( offsetY === true ) {
887
			offsetY = Math.round(elRect.height / 2 - wrapperRect.height / 2);
782
			offsetY = Math.round(el.offsetHeight / 2 - this.wrapper.offsetHeight / 2);
888
		}
783
		}
889
 
784
 
890
		pos.left -= offsetX || 0;
785
		pos.left -= offsetX || 0;
891
		pos.top  -= offsetY || 0;
786
		pos.top  -= offsetY || 0;
892
 
787
 
Line 897... Line 792...
897
 
792
 
898
		this.scrollTo(pos.left, pos.top, time, easing);
793
		this.scrollTo(pos.left, pos.top, time, easing);
899
	},
794
	},
900
 
795
 
901
	_transitionTime: function (time) {
796
	_transitionTime: function (time) {
902
		if (!this.options.useTransition) {
-
 
903
			return;
-
 
904
		}
-
 
905
		time = time || 0;
797
		time = time || 0;
906
		var durationProp = utils.style.transitionDuration;
-
 
907
		if(!durationProp) {
-
 
908
			return;
-
 
909
		}
-
 
910
 
798
 
911
		this.scrollerStyle[durationProp] = time + 'ms';
799
		this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';
912
 
800
 
913
		if ( !time && utils.isBadAndroid ) {
801
		if ( !time && utils.isBadAndroid ) {
914
			this.scrollerStyle[durationProp] = '0.0001ms';
802
			this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
915
			// remove 0.0001ms
-
 
916
			var self = this;
-
 
917
			rAF(function() {
-
 
918
				if(self.scrollerStyle[durationProp] === '0.0001ms') {
-
 
919
					self.scrollerStyle[durationProp] = '0s';
-
 
920
				}
-
 
921
			});
-
 
922
		}
803
		}
923
 
804
 
924
 
805
 
925
		if ( this.indicators ) {
806
		if ( this.indicators ) {
926
			for ( var i = this.indicators.length; i--; ) {
807
			for ( var i = this.indicators.length; i--; ) {
Line 1030... Line 911...
1030
			y = +matrix.top.replace(/[^-\d.]/g, '');
911
			y = +matrix.top.replace(/[^-\d.]/g, '');
1031
		}
912
		}
1032
 
913
 
1033
		return { x: x, y: y };
914
		return { x: x, y: y };
1034
	},
915
	},
-
 
916
 
1035
	_initIndicators: function () {
917
	_initIndicators: function () {
1036
		var interactive = this.options.interactiveScrollbars,
918
		var interactive = this.options.interactiveScrollbars,
1037
			customStyle = typeof this.options.scrollbars != 'string',
919
			customStyle = typeof this.options.scrollbars != 'string',
1038
			indicators = [],
920
			indicators = [],
1039
			indicator;
921
			indicator;
Line 1087... Line 969...
1087
			this.indicators.push( new Indicator(this, indicators[i]) );
969
			this.indicators.push( new Indicator(this, indicators[i]) );
1088
		}
970
		}
1089
 
971
 
1090
		// TODO: check if we can use array.map (wide compatibility and performance issues)
972
		// TODO: check if we can use array.map (wide compatibility and performance issues)
1091
		function _indicatorsMap (fn) {
973
		function _indicatorsMap (fn) {
1092
			if (that.indicators) {
-
 
1093
				for ( var i = that.indicators.length; i--; ) {
974
			for ( var i = that.indicators.length; i--; ) {
1094
					fn.call(that.indicators[i]);
975
				fn.call(that.indicators[i]);
1095
				}
-
 
1096
			}
976
			}
1097
		}
977
		}
1098
 
978
 
1099
		if ( this.options.fadeScrollbars ) {
979
		if ( this.options.fadeScrollbars ) {
1100
			this.on('scrollEnd', function () {
980
			this.on('scrollEnd', function () {
Line 1142... Line 1022...
1142
		utils.addEvent(this.wrapper, 'wheel', this);
1022
		utils.addEvent(this.wrapper, 'wheel', this);
1143
		utils.addEvent(this.wrapper, 'mousewheel', this);
1023
		utils.addEvent(this.wrapper, 'mousewheel', this);
1144
		utils.addEvent(this.wrapper, 'DOMMouseScroll', this);
1024
		utils.addEvent(this.wrapper, 'DOMMouseScroll', this);
1145
 
1025
 
1146
		this.on('destroy', function () {
1026
		this.on('destroy', function () {
1147
			clearTimeout(this.wheelTimeout);
-
 
1148
			this.wheelTimeout = null;
-
 
1149
			utils.removeEvent(this.wrapper, 'wheel', this);
1027
			utils.removeEvent(this.wrapper, 'wheel', this);
1150
			utils.removeEvent(this.wrapper, 'mousewheel', this);
1028
			utils.removeEvent(this.wrapper, 'mousewheel', this);
1151
			utils.removeEvent(this.wrapper, 'DOMMouseScroll', this);
1029
			utils.removeEvent(this.wrapper, 'DOMMouseScroll', this);
1152
		});
1030
		});
1153
	},
1031
	},
Line 1156... Line 1034...
1156
		if ( !this.enabled ) {
1034
		if ( !this.enabled ) {
1157
			return;
1035
			return;
1158
		}
1036
		}
1159
 
1037
 
1160
		e.preventDefault();
1038
		e.preventDefault();
-
 
1039
		e.stopPropagation();
1161
 
1040
 
1162
		var wheelDeltaX, wheelDeltaY,
1041
		var wheelDeltaX, wheelDeltaY,
1163
			newX, newY,
1042
			newX, newY,
1164
			that = this;
1043
			that = this;
1165
 
1044
 
Line 1168... Line 1047...
1168
		}
1047
		}
1169
 
1048
 
1170
		// Execute the scrollEnd event after 400ms the wheel stopped scrolling
1049
		// Execute the scrollEnd event after 400ms the wheel stopped scrolling
1171
		clearTimeout(this.wheelTimeout);
1050
		clearTimeout(this.wheelTimeout);
1172
		this.wheelTimeout = setTimeout(function () {
1051
		this.wheelTimeout = setTimeout(function () {
1173
			if(!that.options.snap) {
-
 
1174
				that._execEvent('scrollEnd');
1052
			that._execEvent('scrollEnd');
1175
			}
-
 
1176
			that.wheelTimeout = undefined;
1053
			that.wheelTimeout = undefined;
1177
		}, 400);
1054
		}, 400);
1178
 
1055
 
1179
		if ( 'deltaX' in e ) {
1056
		if ( 'deltaX' in e ) {
1180
			if (e.deltaMode === 1) {
1057
			if (e.deltaMode === 1) {
Line 1225... Line 1102...
1225
		}
1102
		}
1226
 
1103
 
1227
		newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0);
1104
		newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0);
1228
		newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0);
1105
		newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0);
1229
 
1106
 
1230
		this.directionX = wheelDeltaX > 0 ? -1 : wheelDeltaX < 0 ? 1 : 0;
-
 
1231
		this.directionY = wheelDeltaY > 0 ? -1 : wheelDeltaY < 0 ? 1 : 0;
-
 
1232
 
-
 
1233
		if ( newX > 0 ) {
1107
		if ( newX > 0 ) {
1234
			newX = 0;
1108
			newX = 0;
1235
		} else if ( newX < this.maxScrollX ) {
1109
		} else if ( newX < this.maxScrollX ) {
1236
			newX = this.maxScrollX;
1110
			newX = this.maxScrollX;
1237
		}
1111
		}
Line 1259... Line 1133...
1259
				m = 0, n,
1133
				m = 0, n,
1260
				cx, cy,
1134
				cx, cy,
1261
				x = 0, y,
1135
				x = 0, y,
1262
				stepX = this.options.snapStepX || this.wrapperWidth,
1136
				stepX = this.options.snapStepX || this.wrapperWidth,
1263
				stepY = this.options.snapStepY || this.wrapperHeight,
1137
				stepY = this.options.snapStepY || this.wrapperHeight,
1264
				el,
1138
				el;
1265
				rect;
-
 
1266
 
1139
 
1267
			this.pages = [];
1140
			this.pages = [];
1268
 
1141
 
1269
			if ( !this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight ) {
1142
			if ( !this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight ) {
1270
				return;
1143
				return;
Line 1300... Line 1173...
1300
				el = this.options.snap;
1173
				el = this.options.snap;
1301
				l = el.length;
1174
				l = el.length;
1302
				n = -1;
1175
				n = -1;
1303
 
1176
 
1304
				for ( ; i < l; i++ ) {
1177
				for ( ; i < l; i++ ) {
1305
					rect = utils.getRect(el[i]);
-
 
1306
					if ( i === 0 || rect.left <= utils.getRect(el[i-1]).left ) {
1178
					if ( i === 0 || el[i].offsetLeft <= el[i-1].offsetLeft ) {
1307
						m = 0;
1179
						m = 0;
1308
						n++;
1180
						n++;
1309
					}
1181
					}
1310
 
1182
 
1311
					if ( !this.pages[m] ) {
1183
					if ( !this.pages[m] ) {
1312
						this.pages[m] = [];
1184
						this.pages[m] = [];
1313
					}
1185
					}
1314
 
1186
 
1315
					x = Math.max(-rect.left, this.maxScrollX);
1187
					x = Math.max(-el[i].offsetLeft, this.maxScrollX);
1316
					y = Math.max(-rect.top, this.maxScrollY);
1188
					y = Math.max(-el[i].offsetTop, this.maxScrollY);
1317
					cx = x - Math.round(rect.width / 2);
1189
					cx = x - Math.round(el[i].offsetWidth / 2);
1318
					cy = y - Math.round(rect.height / 2);
1190
					cy = y - Math.round(el[i].offsetHeight / 2);
1319
 
1191
 
1320
					this.pages[m][n] = {
1192
					this.pages[m][n] = {
1321
						x: x,
1193
						x: x,
1322
						y: y,
1194
						y: y,
1323
						width: rect.width,
1195
						width: el[i].offsetWidth,
1324
						height: rect.height,
1196
						height: el[i].offsetHeight,
1325
						cx: cx,
1197
						cx: cx,
1326
						cy: cy
1198
						cy: cy
1327
					};
1199
					};
1328
 
1200
 
1329
					if ( x > this.maxScrollX ) {
1201
					if ( x > this.maxScrollX ) {
Line 1697... Line 1569...
1697
				break;
1569
				break;
1698
			case 'keydown':
1570
			case 'keydown':
1699
				this._key(e);
1571
				this._key(e);
1700
				break;
1572
				break;
1701
			case 'click':
1573
			case 'click':
1702
				if ( this.enabled && !e._constructed ) {
1574
				if ( !e._constructed ) {
1703
					e.preventDefault();
1575
					e.preventDefault();
1704
					e.stopPropagation();
1576
					e.stopPropagation();
1705
				}
1577
				}
1706
				break;
1578
				break;
1707
		}
1579
		}
Line 1786... Line 1658...
1786
		}
1658
		}
1787
	}
1659
	}
1788
 
1660
 
1789
	if ( this.options.fade ) {
1661
	if ( this.options.fade ) {
1790
		this.wrapperStyle[utils.style.transform] = this.scroller.translateZ;
1662
		this.wrapperStyle[utils.style.transform] = this.scroller.translateZ;
1791
		var durationProp = utils.style.transitionDuration;
-
 
1792
		if(!durationProp) {
-
 
1793
			return;
-
 
1794
		}
-
 
1795
		this.wrapperStyle[durationProp] = utils.isBadAndroid ? '0.0001ms' : '0ms';
1663
		this.wrapperStyle[utils.style.transitionDuration] = utils.isBadAndroid ? '0.001s' : '0ms';
1796
		// remove 0.0001ms
-
 
1797
		var self = this;
-
 
1798
		if(utils.isBadAndroid) {
-
 
1799
			rAF(function() {
-
 
1800
				if(self.wrapperStyle[durationProp] === '0.0001ms') {
-
 
1801
					self.wrapperStyle[durationProp] = '0s';
-
 
1802
				}
-
 
1803
			});
-
 
1804
		}
-
 
1805
		this.wrapperStyle.opacity = '0';
1664
		this.wrapperStyle.opacity = '0';
1806
	}
1665
	}
1807
}
1666
}
1808
 
1667
 
1809
Indicator.prototype = {
1668
Indicator.prototype = {
Line 1833... Line 1692...
1833
				break;
1692
				break;
1834
		}
1693
		}
1835
	},
1694
	},
1836
 
1695
 
1837
	destroy: function () {
1696
	destroy: function () {
1838
		if ( this.options.fadeScrollbars ) {
-
 
1839
			clearTimeout(this.fadeTimeout);
-
 
1840
			this.fadeTimeout = null;
-
 
1841
		}
-
 
1842
		if ( this.options.interactive ) {
1697
		if ( this.options.interactive ) {
1843
			utils.removeEvent(this.indicator, 'touchstart', this);
1698
			utils.removeEvent(this.indicator, 'touchstart', this);
1844
			utils.removeEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this);
1699
			utils.removeEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this);
1845
			utils.removeEvent(this.indicator, 'mousedown', this);
1700
			utils.removeEvent(this.indicator, 'mousedown', this);
1846
 
1701
 
Line 1851... Line 1706...
1851
			utils.removeEvent(window, 'touchend', this);
1706
			utils.removeEvent(window, 'touchend', this);
1852
			utils.removeEvent(window, utils.prefixPointerEvent('pointerup'), this);
1707
			utils.removeEvent(window, utils.prefixPointerEvent('pointerup'), this);
1853
			utils.removeEvent(window, 'mouseup', this);
1708
			utils.removeEvent(window, 'mouseup', this);
1854
		}
1709
		}
1855
 
1710
 
1856
		if ( this.options.defaultScrollbars && this.wrapper.parentNode ) {
1711
		if ( this.options.defaultScrollbars ) {
1857
			this.wrapper.parentNode.removeChild(this.wrapper);
1712
			this.wrapper.parentNode.removeChild(this.wrapper);
1858
		}
1713
		}
1859
	},
1714
	},
1860
 
1715
 
1861
	_start: function (e) {
1716
	_start: function (e) {
Line 1951... Line 1806...
1951
		}
1806
		}
1952
	},
1807
	},
1953
 
1808
 
1954
	transitionTime: function (time) {
1809
	transitionTime: function (time) {
1955
		time = time || 0;
1810
		time = time || 0;
1956
		var durationProp = utils.style.transitionDuration;
-
 
1957
		if(!durationProp) {
-
 
1958
			return;
-
 
1959
		}
-
 
1960
 
-
 
1961
		this.indicatorStyle[durationProp] = time + 'ms';
1811
		this.indicatorStyle[utils.style.transitionDuration] = time + 'ms';
1962
 
1812
 
1963
		if ( !time && utils.isBadAndroid ) {
1813
		if ( !time && utils.isBadAndroid ) {
1964
			this.indicatorStyle[durationProp] = '0.0001ms';
1814
			this.indicatorStyle[utils.style.transitionDuration] = '0.001s';
1965
			// remove 0.0001ms
-
 
1966
			var self = this;
-
 
1967
			rAF(function() {
-
 
1968
				if(self.indicatorStyle[durationProp] === '0.0001ms') {
-
 
1969
					self.indicatorStyle[durationProp] = '0s';
-
 
1970
				}
-
 
1971
			});
-
 
1972
		}
1815
		}
1973
	},
1816
	},
1974
 
1817
 
1975
	transitionTimingFunction: function (easing) {
1818
	transitionTimingFunction: function (easing) {
1976
		this.indicatorStyle[utils.style.transitionTimingFunction] = easing;
1819
		this.indicatorStyle[utils.style.transitionTimingFunction] = easing;
Line 2009... Line 1852...
2009
					this.wrapper.style.bottom = '2px';
1852
					this.wrapper.style.bottom = '2px';
2010
				}
1853
				}
2011
			}
1854
			}
2012
		}
1855
		}
2013
 
1856
 
2014
		utils.getRect(this.wrapper);	// force refresh
1857
		var r = this.wrapper.offsetHeight;	// force refresh
2015
 
1858
 
2016
		if ( this.options.listenX ) {
1859
		if ( this.options.listenX ) {
2017
			this.wrapperWidth = this.wrapper.clientWidth;
1860
			this.wrapperWidth = this.wrapper.clientWidth;
2018
			if ( this.options.resize ) {
1861
			if ( this.options.resize ) {
2019
				this.indicatorWidth = Math.max(Math.round(this.wrapperWidth * this.wrapperWidth / (this.scroller.scrollerWidth || this.wrapperWidth || 1)), 8);
1862
				this.indicatorWidth = Math.max(Math.round(this.wrapperWidth * this.wrapperWidth / (this.scroller.scrollerWidth || this.wrapperWidth || 1)), 8);
Line 2030... Line 1873...
2030
			} else {
1873
			} else {
2031
				this.minBoundaryX = 0;
1874
				this.minBoundaryX = 0;
2032
				this.maxBoundaryX = this.maxPosX;
1875
				this.maxBoundaryX = this.maxPosX;
2033
			}
1876
			}
2034
 
1877
 
2035
			this.sizeRatioX = this.options.speedRatioX || (this.scroller.maxScrollX && (this.maxPosX / this.scroller.maxScrollX));
1878
			this.sizeRatioX = this.options.speedRatioX || (this.scroller.maxScrollX && (this.maxPosX / this.scroller.maxScrollX));	
2036
		}
1879
		}
2037
 
1880
 
2038
		if ( this.options.listenY ) {
1881
		if ( this.options.listenY ) {
2039
			this.wrapperHeight = this.wrapper.clientHeight;
1882
			this.wrapperHeight = this.wrapper.clientHeight;
2040
			if ( this.options.resize ) {
1883
			if ( this.options.resize ) {
Line 2159... Line 2002...
2159
 
2002
 
2160
IScroll.utils = utils;
2003
IScroll.utils = utils;
2161
 
2004
 
2162
if ( typeof module != 'undefined' && module.exports ) {
2005
if ( typeof module != 'undefined' && module.exports ) {
2163
	module.exports = IScroll;
2006
	module.exports = IScroll;
2164
} else if ( typeof define == 'function' && define.amd ) {
-
 
2165
        define( function () { return IScroll; } );
-
 
2166
} else {
2007
} else {
2167
	window.IScroll = IScroll;
2008
	window.IScroll = IScroll;
2168
}
2009
}
2169
 
2010
 
2170
})(window, document, Math);
2011
})(window, document, Math);
2171
2012