Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
cubiq committed Jun 2, 2014
1 parent 3b0cfde commit 6019c7a
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 59 deletions.
28 changes: 21 additions & 7 deletions build/iscroll-infinite.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.1.2 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
(function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down Expand Up @@ -47,6 +47,12 @@ var utils = (function () {
el.removeEventListener(type, fn, !!capture);
};

me.prefixPointerEvent = function (pointerEvent) {
return window.MSPointerEvent ?
'MSPointer' + pointerEvent.charAt(9).toUpperCase() + pointerEvent.substr(10):
pointerEvent;
};

me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
var distance = current - start,
speed = Math.abs(distance) / time,
Expand Down Expand Up @@ -80,7 +86,7 @@ var utils = (function () {
hasTransform: _transform !== false,
hasPerspective: _prefixStyle('perspective') in _elementStyle,
hasTouch: 'ontouchstart' in window,
hasPointer: navigator.msPointerEnabled,
hasPointer: window.PointerEvent || window.MSPointerEvent, // IE10 is prefixed
hasTransition: _prefixStyle('transition') in _elementStyle
});

Expand Down Expand Up @@ -155,6 +161,10 @@ var utils = (function () {
mousemove: 2,
mouseup: 2,

pointerdown: 3,
pointermove: 3,
pointerup: 3,

MSPointerDown: 3,
MSPointerMove: 3,
MSPointerUp: 3
Expand Down Expand Up @@ -327,7 +337,7 @@ function IScroll (el, options) {
}

IScroll.prototype = {
version: '5.1.1',
version: '5.1.2',

_init: function () {
this._initEvents();
Expand Down Expand Up @@ -860,10 +870,10 @@ IScroll.prototype = {
}

if ( utils.hasPointer && !this.options.disablePointer ) {
eventType(this.wrapper, 'MSPointerDown', this);
eventType(target, 'MSPointerMove', this);
eventType(target, 'MSPointerCancel', this);
eventType(target, 'MSPointerUp', this);
eventType(this.wrapper, utils.prefixPointerEvent('pointerdown'), this);
eventType(target, utils.prefixPointerEvent('pointermove'), this);
eventType(target, utils.prefixPointerEvent('pointercancel'), this);
eventType(target, utils.prefixPointerEvent('pointerup'), this);
}

if ( utils.hasTouch && !this.options.disableTouch ) {
Expand Down Expand Up @@ -1510,19 +1520,23 @@ IScroll.prototype = {
handleEvent: function (e) {
switch ( e.type ) {
case 'touchstart':
case 'pointerdown':
case 'MSPointerDown':
case 'mousedown':
this._start(e);
break;
case 'touchmove':
case 'pointermove':
case 'MSPointerMove':
case 'mousemove':
this._move(e);
break;
case 'touchend':
case 'pointerup':
case 'MSPointerUp':
case 'mouseup':
case 'touchcancel':
case 'pointercancel':
case 'MSPointerCancel':
case 'mousecancel':
this._end(e);
Expand Down
28 changes: 21 additions & 7 deletions build/iscroll-lite.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.1.2 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
(function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down Expand Up @@ -47,6 +47,12 @@ var utils = (function () {
el.removeEventListener(type, fn, !!capture);
};

me.prefixPointerEvent = function (pointerEvent) {
return window.MSPointerEvent ?
'MSPointer' + pointerEvent.charAt(9).toUpperCase() + pointerEvent.substr(10):
pointerEvent;
};

me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
var distance = current - start,
speed = Math.abs(distance) / time,
Expand Down Expand Up @@ -80,7 +86,7 @@ var utils = (function () {
hasTransform: _transform !== false,
hasPerspective: _prefixStyle('perspective') in _elementStyle,
hasTouch: 'ontouchstart' in window,
hasPointer: navigator.msPointerEnabled,
hasPointer: window.PointerEvent || window.MSPointerEvent, // IE10 is prefixed
hasTransition: _prefixStyle('transition') in _elementStyle
});

Expand Down Expand Up @@ -155,6 +161,10 @@ var utils = (function () {
mousemove: 2,
mouseup: 2,

pointerdown: 3,
pointermove: 3,
pointerup: 3,

MSPointerDown: 3,
MSPointerMove: 3,
MSPointerUp: 3
Expand Down Expand Up @@ -310,7 +320,7 @@ function IScroll (el, options) {
}

IScroll.prototype = {
version: '5.1.1',
version: '5.1.2',

_init: function () {
this._initEvents();
Expand Down Expand Up @@ -800,10 +810,10 @@ IScroll.prototype = {
}

if ( utils.hasPointer && !this.options.disablePointer ) {
eventType(this.wrapper, 'MSPointerDown', this);
eventType(target, 'MSPointerMove', this);
eventType(target, 'MSPointerCancel', this);
eventType(target, 'MSPointerUp', this);
eventType(this.wrapper, utils.prefixPointerEvent('pointerdown'), this);
eventType(target, utils.prefixPointerEvent('pointermove'), this);
eventType(target, utils.prefixPointerEvent('pointercancel'), this);
eventType(target, utils.prefixPointerEvent('pointerup'), this);
}

if ( utils.hasTouch && !this.options.disableTouch ) {
Expand Down Expand Up @@ -875,19 +885,23 @@ IScroll.prototype = {
handleEvent: function (e) {
switch ( e.type ) {
case 'touchstart':
case 'pointerdown':
case 'MSPointerDown':
case 'mousedown':
this._start(e);
break;
case 'touchmove':
case 'pointermove':
case 'MSPointerMove':
case 'mousemove':
this._move(e);
break;
case 'touchend':
case 'pointerup':
case 'MSPointerUp':
case 'mouseup':
case 'touchcancel':
case 'pointercancel':
case 'MSPointerCancel':
case 'mousecancel':
this._end(e);
Expand Down
46 changes: 32 additions & 14 deletions build/iscroll-probe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
/*! iScroll v5.1.2 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
(function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
Expand Down Expand Up @@ -47,6 +47,12 @@ var utils = (function () {
el.removeEventListener(type, fn, !!capture);
};

me.prefixPointerEvent = function (pointerEvent) {
return window.MSPointerEvent ?
'MSPointer' + pointerEvent.charAt(9).toUpperCase() + pointerEvent.substr(10):
pointerEvent;
};

me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
var distance = current - start,
speed = Math.abs(distance) / time,
Expand Down Expand Up @@ -80,7 +86,7 @@ var utils = (function () {
hasTransform: _transform !== false,
hasPerspective: _prefixStyle('perspective') in _elementStyle,
hasTouch: 'ontouchstart' in window,
hasPointer: navigator.msPointerEnabled,
hasPointer: window.PointerEvent || window.MSPointerEvent, // IE10 is prefixed
hasTransition: _prefixStyle('transition') in _elementStyle
});

Expand Down Expand Up @@ -155,6 +161,10 @@ var utils = (function () {
mousemove: 2,
mouseup: 2,

pointerdown: 3,
pointermove: 3,
pointerup: 3,

MSPointerDown: 3,
MSPointerMove: 3,
MSPointerUp: 3
Expand Down Expand Up @@ -325,7 +335,7 @@ function IScroll (el, options) {
}

IScroll.prototype = {
version: '5.1.1',
version: '5.1.2',

_init: function () {
this._initEvents();
Expand Down Expand Up @@ -878,10 +888,10 @@ IScroll.prototype = {
}

if ( utils.hasPointer && !this.options.disablePointer ) {
eventType(this.wrapper, 'MSPointerDown', this);
eventType(target, 'MSPointerMove', this);
eventType(target, 'MSPointerCancel', this);
eventType(target, 'MSPointerUp', this);
eventType(this.wrapper, utils.prefixPointerEvent('pointerdown'), this);
eventType(target, utils.prefixPointerEvent('pointermove'), this);
eventType(target, utils.prefixPointerEvent('pointercancel'), this);
eventType(target, utils.prefixPointerEvent('pointerup'), this);
}

if ( utils.hasTouch && !this.options.disableTouch ) {
Expand Down Expand Up @@ -1534,19 +1544,23 @@ IScroll.prototype = {
handleEvent: function (e) {
switch ( e.type ) {
case 'touchstart':
case 'pointerdown':
case 'MSPointerDown':
case 'mousedown':
this._start(e);
break;
case 'touchmove':
case 'pointermove':
case 'MSPointerMove':
case 'mousemove':
this._move(e);
break;
case 'touchend':
case 'pointerup':
case 'MSPointerUp':
case 'mouseup':
case 'touchcancel':
case 'pointercancel':
case 'MSPointerCancel':
case 'mousecancel':
this._end(e);
Expand Down Expand Up @@ -1648,8 +1662,8 @@ function Indicator (scroller, options) {
utils.addEvent(window, 'touchend', this);
}
if ( !this.options.disablePointer ) {
utils.addEvent(this.indicator, 'MSPointerDown', this);
utils.addEvent(window, 'MSPointerUp', this);
utils.addEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this);
utils.addEvent(window, utils.prefixPointerEvent('pointerup'), this);
}
if ( !this.options.disableMouse ) {
utils.addEvent(this.indicator, 'mousedown', this);
Expand All @@ -1668,19 +1682,23 @@ Indicator.prototype = {
handleEvent: function (e) {
switch ( e.type ) {
case 'touchstart':
case 'pointerdown':
case 'MSPointerDown':
case 'mousedown':
this._start(e);
break;
case 'touchmove':
case 'pointermove':
case 'MSPointerMove':
case 'mousemove':
this._move(e);
break;
case 'touchend':
case 'pointerup':
case 'MSPointerUp':
case 'mouseup':
case 'touchcancel':
case 'pointercancel':
case 'MSPointerCancel':
case 'mousecancel':
this._end(e);
Expand All @@ -1691,15 +1709,15 @@ Indicator.prototype = {
destroy: function () {
if ( this.options.interactive ) {
utils.removeEvent(this.indicator, 'touchstart', this);
utils.removeEvent(this.indicator, 'MSPointerDown', this);
utils.removeEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this);
utils.removeEvent(this.indicator, 'mousedown', this);

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

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

Expand Down Expand Up @@ -1727,7 +1745,7 @@ Indicator.prototype = {
utils.addEvent(window, 'touchmove', this);
}
if ( !this.options.disablePointer ) {
utils.addEvent(window, 'MSPointerMove', this);
utils.addEvent(window, utils.prefixPointerEvent('pointermove'), this);
}
if ( !this.options.disableMouse ) {
utils.addEvent(window, 'mousemove', this);
Expand Down Expand Up @@ -1785,7 +1803,7 @@ Indicator.prototype = {
e.stopPropagation();

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

if ( this.scroller.options.snap ) {
Expand Down
Loading

0 comments on commit 6019c7a

Please sign in to comment.