|
|
|
@ -2,26 +2,26 @@
|
|
|
|
* Simple gesture controllers with some common gestures that emit
|
|
|
|
* Simple gesture controllers with some common gestures that emit
|
|
|
|
* gesture events.
|
|
|
|
* gesture events.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Ported from github.com/EightMedia/ion.Gestures.js - thanks!
|
|
|
|
* Ported from github.com/EightMedia/ionic.Gestures.js - thanks!
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
(function(window, document, ion) {
|
|
|
|
(function(window, document, ionic) {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* ion.Gestures
|
|
|
|
* ionic.Gestures
|
|
|
|
* use this to create instances
|
|
|
|
* use this to create instances
|
|
|
|
* @param {HTMLElement} element
|
|
|
|
* @param {HTMLElement} element
|
|
|
|
* @param {Object} options
|
|
|
|
* @param {Object} options
|
|
|
|
* @returns {ion.Gestures.Instance}
|
|
|
|
* @returns {ionic.Gestures.Instance}
|
|
|
|
* @constructor
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
ion.Gesture = function(element, options) {
|
|
|
|
ionic.Gesture = function(element, options) {
|
|
|
|
return new ion.Gestures.Instance(element, options || {});
|
|
|
|
return new ionic.Gestures.Instance(element, options || {});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ion.Gestures = {};
|
|
|
|
ionic.Gestures = {};
|
|
|
|
|
|
|
|
|
|
|
|
// default settings
|
|
|
|
// default settings
|
|
|
|
ion.Gestures.defaults = {
|
|
|
|
ionic.Gestures.defaults = {
|
|
|
|
// add styles and attributes to the element to prevent the browser from doing
|
|
|
|
// add styles and attributes to the element to prevent the browser from doing
|
|
|
|
// its native behavior. this doesnt prevent the scrolling, but cancels
|
|
|
|
// its native behavior. this doesnt prevent the scrolling, but cancels
|
|
|
|
// the contextmenu, tap highlighting etc
|
|
|
|
// the contextmenu, tap highlighting etc
|
|
|
|
@ -42,66 +42,66 @@
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// detect touchevents
|
|
|
|
// detect touchevents
|
|
|
|
ion.Gestures.HAS_POINTEREVENTS = window.navigator.pointerEnabled || window.navigator.msPointerEnabled;
|
|
|
|
ionic.Gestures.HAS_POINTEREVENTS = window.navigator.pointerEnabled || window.navigator.msPointerEnabled;
|
|
|
|
ion.Gestures.HAS_TOUCHEVENTS = ('ontouchstart' in window);
|
|
|
|
ionic.Gestures.HAS_TOUCHEVENTS = ('ontouchstart' in window);
|
|
|
|
|
|
|
|
|
|
|
|
// dont use mouseevents on mobile devices
|
|
|
|
// dont use mouseevents on mobile devices
|
|
|
|
ion.Gestures.MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android|silk/i;
|
|
|
|
ionic.Gestures.MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android|silk/i;
|
|
|
|
ion.Gestures.NO_MOUSEEVENTS = ion.Gestures.HAS_TOUCHEVENTS && window.navigator.userAgent.match(ion.Gestures.MOBILE_REGEX);
|
|
|
|
ionic.Gestures.NO_MOUSEEVENTS = ionic.Gestures.HAS_TOUCHEVENTS && window.navigator.userAgent.match(ionic.Gestures.MOBILE_REGEX);
|
|
|
|
|
|
|
|
|
|
|
|
// eventtypes per touchevent (start, move, end)
|
|
|
|
// eventtypes per touchevent (start, move, end)
|
|
|
|
// are filled by ion.Gestures.event.determineEventTypes on setup
|
|
|
|
// are filled by ionic.Gestures.event.determineEventTypes on setup
|
|
|
|
ion.Gestures.EVENT_TYPES = {};
|
|
|
|
ionic.Gestures.EVENT_TYPES = {};
|
|
|
|
|
|
|
|
|
|
|
|
// direction defines
|
|
|
|
// direction defines
|
|
|
|
ion.Gestures.DIRECTION_DOWN = 'down';
|
|
|
|
ionic.Gestures.DIRECTION_DOWN = 'down';
|
|
|
|
ion.Gestures.DIRECTION_LEFT = 'left';
|
|
|
|
ionic.Gestures.DIRECTION_LEFT = 'left';
|
|
|
|
ion.Gestures.DIRECTION_UP = 'up';
|
|
|
|
ionic.Gestures.DIRECTION_UP = 'up';
|
|
|
|
ion.Gestures.DIRECTION_RIGHT = 'right';
|
|
|
|
ionic.Gestures.DIRECTION_RIGHT = 'right';
|
|
|
|
|
|
|
|
|
|
|
|
// pointer type
|
|
|
|
// pointer type
|
|
|
|
ion.Gestures.POINTER_MOUSE = 'mouse';
|
|
|
|
ionic.Gestures.POINTER_MOUSE = 'mouse';
|
|
|
|
ion.Gestures.POINTER_TOUCH = 'touch';
|
|
|
|
ionic.Gestures.POINTER_TOUCH = 'touch';
|
|
|
|
ion.Gestures.POINTER_PEN = 'pen';
|
|
|
|
ionic.Gestures.POINTER_PEN = 'pen';
|
|
|
|
|
|
|
|
|
|
|
|
// touch event defines
|
|
|
|
// touch event defines
|
|
|
|
ion.Gestures.EVENT_START = 'start';
|
|
|
|
ionic.Gestures.EVENT_START = 'start';
|
|
|
|
ion.Gestures.EVENT_MOVE = 'move';
|
|
|
|
ionic.Gestures.EVENT_MOVE = 'move';
|
|
|
|
ion.Gestures.EVENT_END = 'end';
|
|
|
|
ionic.Gestures.EVENT_END = 'end';
|
|
|
|
|
|
|
|
|
|
|
|
// hammer document where the base events are added at
|
|
|
|
// hammer document where the base events are added at
|
|
|
|
ion.Gestures.DOCUMENT = window.document;
|
|
|
|
ionic.Gestures.DOCUMENT = window.document;
|
|
|
|
|
|
|
|
|
|
|
|
// plugins namespace
|
|
|
|
// plugins namespace
|
|
|
|
ion.Gestures.plugins = {};
|
|
|
|
ionic.Gestures.plugins = {};
|
|
|
|
|
|
|
|
|
|
|
|
// if the window events are set...
|
|
|
|
// if the window events are set...
|
|
|
|
ion.Gestures.READY = false;
|
|
|
|
ionic.Gestures.READY = false;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* setup events to detect gestures on the document
|
|
|
|
* setup events to detect gestures on the document
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function setup() {
|
|
|
|
function setup() {
|
|
|
|
if(ion.Gestures.READY) {
|
|
|
|
if(ionic.Gestures.READY) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// find what eventtypes we add listeners to
|
|
|
|
// find what eventtypes we add listeners to
|
|
|
|
ion.Gestures.event.determineEventTypes();
|
|
|
|
ionic.Gestures.event.determineEventTypes();
|
|
|
|
|
|
|
|
|
|
|
|
// Register all gestures inside ion.Gestures.gestures
|
|
|
|
// Register all gestures inside ionic.Gestures.gestures
|
|
|
|
for(var name in ion.Gestures.gestures) {
|
|
|
|
for(var name in ionic.Gestures.gestures) {
|
|
|
|
if(ion.Gestures.gestures.hasOwnProperty(name)) {
|
|
|
|
if(ionic.Gestures.gestures.hasOwnProperty(name)) {
|
|
|
|
ion.Gestures.detection.register(ion.Gestures.gestures[name]);
|
|
|
|
ionic.Gestures.detection.register(ionic.Gestures.gestures[name]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Add touch events on the document
|
|
|
|
// Add touch events on the document
|
|
|
|
ion.Gestures.event.onTouch(ion.Gestures.DOCUMENT, ion.Gestures.EVENT_MOVE, ion.Gestures.detection.detect);
|
|
|
|
ionic.Gestures.event.onTouch(ionic.Gestures.DOCUMENT, ionic.Gestures.EVENT_MOVE, ionic.Gestures.detection.detect);
|
|
|
|
ion.Gestures.event.onTouch(ion.Gestures.DOCUMENT, ion.Gestures.EVENT_END, ion.Gestures.detection.detect);
|
|
|
|
ionic.Gestures.event.onTouch(ionic.Gestures.DOCUMENT, ionic.Gestures.EVENT_END, ionic.Gestures.detection.detect);
|
|
|
|
|
|
|
|
|
|
|
|
// ion.Gestures is ready...!
|
|
|
|
// ionic.Gestures is ready...!
|
|
|
|
ion.Gestures.READY = true;
|
|
|
|
ionic.Gestures.READY = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -109,10 +109,10 @@
|
|
|
|
* all methods should return the instance itself, so it is chainable.
|
|
|
|
* all methods should return the instance itself, so it is chainable.
|
|
|
|
* @param {HTMLElement} element
|
|
|
|
* @param {HTMLElement} element
|
|
|
|
* @param {Object} [options={}]
|
|
|
|
* @param {Object} [options={}]
|
|
|
|
* @returns {ion.Gestures.Instance}
|
|
|
|
* @returns {ionic.Gestures.Instance}
|
|
|
|
* @constructor
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
ion.Gestures.Instance = function(element, options) {
|
|
|
|
ionic.Gestures.Instance = function(element, options) {
|
|
|
|
var self = this;
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
|
|
// A null element was passed into the instance, which means
|
|
|
|
// A null element was passed into the instance, which means
|
|
|
|
@ -123,7 +123,7 @@
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// setup ion.GesturesJS window events and register all gestures
|
|
|
|
// setup ionic.GesturesJS window events and register all gestures
|
|
|
|
// this also sets up the default options
|
|
|
|
// this also sets up the default options
|
|
|
|
setup();
|
|
|
|
setup();
|
|
|
|
|
|
|
|
|
|
|
|
@ -133,19 +133,19 @@
|
|
|
|
this.enabled = true;
|
|
|
|
this.enabled = true;
|
|
|
|
|
|
|
|
|
|
|
|
// merge options
|
|
|
|
// merge options
|
|
|
|
this.options = ion.Gestures.utils.extend(
|
|
|
|
this.options = ionic.Gestures.utils.extend(
|
|
|
|
ion.Gestures.utils.extend({}, ion.Gestures.defaults),
|
|
|
|
ionic.Gestures.utils.extend({}, ionic.Gestures.defaults),
|
|
|
|
options || {});
|
|
|
|
options || {});
|
|
|
|
|
|
|
|
|
|
|
|
// add some css to the element to prevent the browser from doing its native behavoir
|
|
|
|
// add some css to the element to prevent the browser from doing its native behavoir
|
|
|
|
if(this.options.stop_browser_behavior) {
|
|
|
|
if(this.options.stop_browser_behavior) {
|
|
|
|
ion.Gestures.utils.stopDefaultBrowserBehavior(this.element, this.options.stop_browser_behavior);
|
|
|
|
ionic.Gestures.utils.stopDefaultBrowserBehavior(this.element, this.options.stop_browser_behavior);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// start detection on touchstart
|
|
|
|
// start detection on touchstart
|
|
|
|
ion.Gestures.event.onTouch(element, ion.Gestures.EVENT_START, function(ev) {
|
|
|
|
ionic.Gestures.event.onTouch(element, ionic.Gestures.EVENT_START, function(ev) {
|
|
|
|
if(self.enabled) {
|
|
|
|
if(self.enabled) {
|
|
|
|
ion.Gestures.detection.startDetect(self, ev);
|
|
|
|
ionic.Gestures.detection.startDetect(self, ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@ -154,12 +154,12 @@
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ion.Gestures.Instance.prototype = {
|
|
|
|
ionic.Gestures.Instance.prototype = {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* bind events to the instance
|
|
|
|
* bind events to the instance
|
|
|
|
* @param {String} gesture
|
|
|
|
* @param {String} gesture
|
|
|
|
* @param {Function} handler
|
|
|
|
* @param {Function} handler
|
|
|
|
* @returns {ion.Gestures.Instance}
|
|
|
|
* @returns {ionic.Gestures.Instance}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
on: function onEvent(gesture, handler){
|
|
|
|
on: function onEvent(gesture, handler){
|
|
|
|
var gestures = gesture.split(' ');
|
|
|
|
var gestures = gesture.split(' ');
|
|
|
|
@ -174,7 +174,7 @@
|
|
|
|
* unbind events to the instance
|
|
|
|
* unbind events to the instance
|
|
|
|
* @param {String} gesture
|
|
|
|
* @param {String} gesture
|
|
|
|
* @param {Function} handler
|
|
|
|
* @param {Function} handler
|
|
|
|
* @returns {ion.Gestures.Instance}
|
|
|
|
* @returns {ionic.Gestures.Instance}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
off: function offEvent(gesture, handler){
|
|
|
|
off: function offEvent(gesture, handler){
|
|
|
|
var gestures = gesture.split(' ');
|
|
|
|
var gestures = gesture.split(' ');
|
|
|
|
@ -189,18 +189,18 @@
|
|
|
|
* trigger gesture event
|
|
|
|
* trigger gesture event
|
|
|
|
* @param {String} gesture
|
|
|
|
* @param {String} gesture
|
|
|
|
* @param {Object} eventData
|
|
|
|
* @param {Object} eventData
|
|
|
|
* @returns {ion.Gestures.Instance}
|
|
|
|
* @returns {ionic.Gestures.Instance}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
trigger: function triggerEvent(gesture, eventData){
|
|
|
|
trigger: function triggerEvent(gesture, eventData){
|
|
|
|
// create DOM event
|
|
|
|
// create DOM event
|
|
|
|
var event = ion.Gestures.DOCUMENT.createEvent('Event');
|
|
|
|
var event = ionic.Gestures.DOCUMENT.createEvent('Event');
|
|
|
|
event.initEvent(gesture, true, true);
|
|
|
|
event.initEvent(gesture, true, true);
|
|
|
|
event.gesture = eventData;
|
|
|
|
event.gesture = eventData;
|
|
|
|
|
|
|
|
|
|
|
|
// trigger on the target if it is in the instance element,
|
|
|
|
// trigger on the target if it is in the instance element,
|
|
|
|
// this is for event delegation tricks
|
|
|
|
// this is for event delegation tricks
|
|
|
|
var element = this.element;
|
|
|
|
var element = this.element;
|
|
|
|
if(ion.Gestures.utils.hasParent(eventData.target, element)) {
|
|
|
|
if(ionic.Gestures.utils.hasParent(eventData.target, element)) {
|
|
|
|
element = eventData.target;
|
|
|
|
element = eventData.target;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -212,7 +212,7 @@
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* enable of disable hammer.js detection
|
|
|
|
* enable of disable hammer.js detection
|
|
|
|
* @param {Boolean} state
|
|
|
|
* @param {Boolean} state
|
|
|
|
* @returns {ion.Gestures.Instance}
|
|
|
|
* @returns {ionic.Gestures.Instance}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
enable: function enable(state) {
|
|
|
|
enable: function enable(state) {
|
|
|
|
this.enabled = state;
|
|
|
|
this.enabled = state;
|
|
|
|
@ -243,7 +243,7 @@
|
|
|
|
var touch_triggered = false;
|
|
|
|
var touch_triggered = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ion.Gestures.event = {
|
|
|
|
ionic.Gestures.event = {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* simple addEventListener
|
|
|
|
* simple addEventListener
|
|
|
|
* @param {HTMLElement} element
|
|
|
|
* @param {HTMLElement} element
|
|
|
|
@ -261,13 +261,13 @@
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* touch events with mouse fallback
|
|
|
|
* touch events with mouse fallback
|
|
|
|
* @param {HTMLElement} element
|
|
|
|
* @param {HTMLElement} element
|
|
|
|
* @param {String} eventType like ion.Gestures.EVENT_MOVE
|
|
|
|
* @param {String} eventType like ionic.Gestures.EVENT_MOVE
|
|
|
|
* @param {Function} handler
|
|
|
|
* @param {Function} handler
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
onTouch: function onTouch(element, eventType, handler) {
|
|
|
|
onTouch: function onTouch(element, eventType, handler) {
|
|
|
|
var self = this;
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
|
|
this.bindDom(element, ion.Gestures.EVENT_TYPES[eventType], function bindDomOnTouch(ev) {
|
|
|
|
this.bindDom(element, ionic.Gestures.EVENT_TYPES[eventType], function bindDomOnTouch(ev) {
|
|
|
|
var sourceEventType = ev.type.toLowerCase();
|
|
|
|
var sourceEventType = ev.type.toLowerCase();
|
|
|
|
|
|
|
|
|
|
|
|
// onmouseup, but when touchend has been fired we do nothing.
|
|
|
|
// onmouseup, but when touchend has been fired we do nothing.
|
|
|
|
@ -303,8 +303,8 @@
|
|
|
|
// and we are now handling a mouse event, we stop that to prevent conflicts
|
|
|
|
// and we are now handling a mouse event, we stop that to prevent conflicts
|
|
|
|
if(enable_detect) {
|
|
|
|
if(enable_detect) {
|
|
|
|
// update pointerevent
|
|
|
|
// update pointerevent
|
|
|
|
if(ion.Gestures.HAS_POINTEREVENTS && eventType != ion.Gestures.EVENT_END) {
|
|
|
|
if(ionic.Gestures.HAS_POINTEREVENTS && eventType != ionic.Gestures.EVENT_END) {
|
|
|
|
count_touches = ion.Gestures.PointerEvent.updatePointer(eventType, ev);
|
|
|
|
count_touches = ionic.Gestures.PointerEvent.updatePointer(eventType, ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// touch
|
|
|
|
// touch
|
|
|
|
else if(sourceEventType.match(/touch/)) {
|
|
|
|
else if(sourceEventType.match(/touch/)) {
|
|
|
|
@ -317,12 +317,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
// if we are in a end event, but when we remove one touch and
|
|
|
|
// if we are in a end event, but when we remove one touch and
|
|
|
|
// we still have enough, set eventType to move
|
|
|
|
// we still have enough, set eventType to move
|
|
|
|
if(count_touches > 0 && eventType == ion.Gestures.EVENT_END) {
|
|
|
|
if(count_touches > 0 && eventType == ionic.Gestures.EVENT_END) {
|
|
|
|
eventType = ion.Gestures.EVENT_MOVE;
|
|
|
|
eventType = ionic.Gestures.EVENT_MOVE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// no touches, force the end event
|
|
|
|
// no touches, force the end event
|
|
|
|
else if(!count_touches) {
|
|
|
|
else if(!count_touches) {
|
|
|
|
eventType = ion.Gestures.EVENT_END;
|
|
|
|
eventType = ionic.Gestures.EVENT_END;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// store the last move event
|
|
|
|
// store the last move event
|
|
|
|
@ -331,11 +331,11 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// trigger the handler
|
|
|
|
// trigger the handler
|
|
|
|
handler.call(ion.Gestures.detection, self.collectEventData(element, eventType, self.getTouchList(last_move_event, eventType), ev));
|
|
|
|
handler.call(ionic.Gestures.detection, self.collectEventData(element, eventType, self.getTouchList(last_move_event, eventType), ev));
|
|
|
|
|
|
|
|
|
|
|
|
// remove pointerevent from list
|
|
|
|
// remove pointerevent from list
|
|
|
|
if(ion.Gestures.HAS_POINTEREVENTS && eventType == ion.Gestures.EVENT_END) {
|
|
|
|
if(ionic.Gestures.HAS_POINTEREVENTS && eventType == ionic.Gestures.EVENT_END) {
|
|
|
|
count_touches = ion.Gestures.PointerEvent.updatePointer(eventType, ev);
|
|
|
|
count_touches = ionic.Gestures.PointerEvent.updatePointer(eventType, ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -346,7 +346,7 @@
|
|
|
|
last_move_event = null;
|
|
|
|
last_move_event = null;
|
|
|
|
enable_detect = false;
|
|
|
|
enable_detect = false;
|
|
|
|
touch_triggered = false;
|
|
|
|
touch_triggered = false;
|
|
|
|
ion.Gestures.PointerEvent.reset();
|
|
|
|
ionic.Gestures.PointerEvent.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -354,18 +354,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* we have different events for each device/browser
|
|
|
|
* we have different events for each device/browser
|
|
|
|
* determine what we need and set them in the ion.Gestures.EVENT_TYPES constant
|
|
|
|
* determine what we need and set them in the ionic.Gestures.EVENT_TYPES constant
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
determineEventTypes: function determineEventTypes() {
|
|
|
|
determineEventTypes: function determineEventTypes() {
|
|
|
|
// determine the eventtype we want to set
|
|
|
|
// determine the eventtype we want to set
|
|
|
|
var types;
|
|
|
|
var types;
|
|
|
|
|
|
|
|
|
|
|
|
// pointerEvents magic
|
|
|
|
// pointerEvents magic
|
|
|
|
if(ion.Gestures.HAS_POINTEREVENTS) {
|
|
|
|
if(ionic.Gestures.HAS_POINTEREVENTS) {
|
|
|
|
types = ion.Gestures.PointerEvent.getEvents();
|
|
|
|
types = ionic.Gestures.PointerEvent.getEvents();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// on Android, iOS, blackberry, windows mobile we dont want any mouseevents
|
|
|
|
// on Android, iOS, blackberry, windows mobile we dont want any mouseevents
|
|
|
|
else if(ion.Gestures.NO_MOUSEEVENTS) {
|
|
|
|
else if(ionic.Gestures.NO_MOUSEEVENTS) {
|
|
|
|
types = [
|
|
|
|
types = [
|
|
|
|
'touchstart',
|
|
|
|
'touchstart',
|
|
|
|
'touchmove',
|
|
|
|
'touchmove',
|
|
|
|
@ -380,9 +380,9 @@
|
|
|
|
'touchend touchcancel mouseup'];
|
|
|
|
'touchend touchcancel mouseup'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ion.Gestures.EVENT_TYPES[ion.Gestures.EVENT_START] = types[0];
|
|
|
|
ionic.Gestures.EVENT_TYPES[ionic.Gestures.EVENT_START] = types[0];
|
|
|
|
ion.Gestures.EVENT_TYPES[ion.Gestures.EVENT_MOVE] = types[1];
|
|
|
|
ionic.Gestures.EVENT_TYPES[ionic.Gestures.EVENT_MOVE] = types[1];
|
|
|
|
ion.Gestures.EVENT_TYPES[ion.Gestures.EVENT_END] = types[2];
|
|
|
|
ionic.Gestures.EVENT_TYPES[ionic.Gestures.EVENT_END] = types[2];
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -393,8 +393,8 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
getTouchList: function getTouchList(ev/*, eventType*/) {
|
|
|
|
getTouchList: function getTouchList(ev/*, eventType*/) {
|
|
|
|
// get the fake pointerEvent touchlist
|
|
|
|
// get the fake pointerEvent touchlist
|
|
|
|
if(ion.Gestures.HAS_POINTEREVENTS) {
|
|
|
|
if(ionic.Gestures.HAS_POINTEREVENTS) {
|
|
|
|
return ion.Gestures.PointerEvent.getTouchList();
|
|
|
|
return ionic.Gestures.PointerEvent.getTouchList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// get the touchlist
|
|
|
|
// get the touchlist
|
|
|
|
else if(ev.touches) {
|
|
|
|
else if(ev.touches) {
|
|
|
|
@ -409,21 +409,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* collect event data for ion.Gestures js
|
|
|
|
* collect event data for ionic.Gestures js
|
|
|
|
* @param {HTMLElement} element
|
|
|
|
* @param {HTMLElement} element
|
|
|
|
* @param {String} eventType like ion.Gestures.EVENT_MOVE
|
|
|
|
* @param {String} eventType like ionic.Gestures.EVENT_MOVE
|
|
|
|
* @param {Object} eventData
|
|
|
|
* @param {Object} eventData
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
collectEventData: function collectEventData(element, eventType, touches, ev) {
|
|
|
|
collectEventData: function collectEventData(element, eventType, touches, ev) {
|
|
|
|
|
|
|
|
|
|
|
|
// find out pointerType
|
|
|
|
// find out pointerType
|
|
|
|
var pointerType = ion.Gestures.POINTER_TOUCH;
|
|
|
|
var pointerType = ionic.Gestures.POINTER_TOUCH;
|
|
|
|
if(ev.type.match(/mouse/) || ion.Gestures.PointerEvent.matchType(ion.Gestures.POINTER_MOUSE, ev)) {
|
|
|
|
if(ev.type.match(/mouse/) || ionic.Gestures.PointerEvent.matchType(ionic.Gestures.POINTER_MOUSE, ev)) {
|
|
|
|
pointerType = ion.Gestures.POINTER_MOUSE;
|
|
|
|
pointerType = ionic.Gestures.POINTER_MOUSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
center : ion.Gestures.utils.getCenter(touches),
|
|
|
|
center : ionic.Gestures.utils.getCenter(touches),
|
|
|
|
timeStamp : new Date().getTime(),
|
|
|
|
timeStamp : new Date().getTime(),
|
|
|
|
target : ev.target,
|
|
|
|
target : ev.target,
|
|
|
|
touches : touches,
|
|
|
|
touches : touches,
|
|
|
|
@ -458,13 +458,13 @@
|
|
|
|
* @return {*}
|
|
|
|
* @return {*}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
stopDetect: function() {
|
|
|
|
stopDetect: function() {
|
|
|
|
return ion.Gestures.detection.stopDetect();
|
|
|
|
return ionic.Gestures.detection.stopDetect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ion.Gestures.PointerEvent = {
|
|
|
|
ionic.Gestures.PointerEvent = {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* holds all pointers
|
|
|
|
* holds all pointers
|
|
|
|
* @type {Object}
|
|
|
|
* @type {Object}
|
|
|
|
@ -488,11 +488,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* update the position of a pointer
|
|
|
|
* update the position of a pointer
|
|
|
|
* @param {String} type ion.Gestures.EVENT_END
|
|
|
|
* @param {String} type ionic.Gestures.EVENT_END
|
|
|
|
* @param {Object} pointerEvent
|
|
|
|
* @param {Object} pointerEvent
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
updatePointer: function(type, pointerEvent) {
|
|
|
|
updatePointer: function(type, pointerEvent) {
|
|
|
|
if(type == ion.Gestures.EVENT_END) {
|
|
|
|
if(type == ionic.Gestures.EVENT_END) {
|
|
|
|
this.pointers = {};
|
|
|
|
this.pointers = {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
@ -505,7 +505,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* check if ev matches pointertype
|
|
|
|
* check if ev matches pointertype
|
|
|
|
* @param {String} pointerType ion.Gestures.POINTER_MOUSE
|
|
|
|
* @param {String} pointerType ionic.Gestures.POINTER_MOUSE
|
|
|
|
* @param {PointerEvent} ev
|
|
|
|
* @param {PointerEvent} ev
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
matchType: function(pointerType, ev) {
|
|
|
|
matchType: function(pointerType, ev) {
|
|
|
|
@ -514,9 +514,9 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var types = {};
|
|
|
|
var types = {};
|
|
|
|
types[ion.Gestures.POINTER_MOUSE] = (ev.pointerType == ev.MSPOINTER_TYPE_MOUSE || ev.pointerType == ion.Gestures.POINTER_MOUSE);
|
|
|
|
types[ionic.Gestures.POINTER_MOUSE] = (ev.pointerType == ev.MSPOINTER_TYPE_MOUSE || ev.pointerType == ionic.Gestures.POINTER_MOUSE);
|
|
|
|
types[ion.Gestures.POINTER_TOUCH] = (ev.pointerType == ev.MSPOINTER_TYPE_TOUCH || ev.pointerType == ion.Gestures.POINTER_TOUCH);
|
|
|
|
types[ionic.Gestures.POINTER_TOUCH] = (ev.pointerType == ev.MSPOINTER_TYPE_TOUCH || ev.pointerType == ionic.Gestures.POINTER_TOUCH);
|
|
|
|
types[ion.Gestures.POINTER_PEN] = (ev.pointerType == ev.MSPOINTER_TYPE_PEN || ev.pointerType == ion.Gestures.POINTER_PEN);
|
|
|
|
types[ionic.Gestures.POINTER_PEN] = (ev.pointerType == ev.MSPOINTER_TYPE_PEN || ev.pointerType == ionic.Gestures.POINTER_PEN);
|
|
|
|
return types[pointerType];
|
|
|
|
return types[pointerType];
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
@ -541,7 +541,7 @@
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ion.Gestures.utils = {
|
|
|
|
ionic.Gestures.utils = {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* extend method,
|
|
|
|
* extend method,
|
|
|
|
* also used for cloning when dest is an empty object
|
|
|
|
* also used for cloning when dest is an empty object
|
|
|
|
@ -631,17 +631,17 @@
|
|
|
|
* angle to direction define
|
|
|
|
* angle to direction define
|
|
|
|
* @param {Touch} touch1
|
|
|
|
* @param {Touch} touch1
|
|
|
|
* @param {Touch} touch2
|
|
|
|
* @param {Touch} touch2
|
|
|
|
* @returns {String} direction constant, like ion.Gestures.DIRECTION_LEFT
|
|
|
|
* @returns {String} direction constant, like ionic.Gestures.DIRECTION_LEFT
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
getDirection: function getDirection(touch1, touch2) {
|
|
|
|
getDirection: function getDirection(touch1, touch2) {
|
|
|
|
var x = Math.abs(touch1.pageX - touch2.pageX),
|
|
|
|
var x = Math.abs(touch1.pageX - touch2.pageX),
|
|
|
|
y = Math.abs(touch1.pageY - touch2.pageY);
|
|
|
|
y = Math.abs(touch1.pageY - touch2.pageY);
|
|
|
|
|
|
|
|
|
|
|
|
if(x >= y) {
|
|
|
|
if(x >= y) {
|
|
|
|
return touch1.pageX - touch2.pageX > 0 ? ion.Gestures.DIRECTION_LEFT : ion.Gestures.DIRECTION_RIGHT;
|
|
|
|
return touch1.pageX - touch2.pageX > 0 ? ionic.Gestures.DIRECTION_LEFT : ionic.Gestures.DIRECTION_RIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
return touch1.pageY - touch2.pageY > 0 ? ion.Gestures.DIRECTION_UP : ion.Gestures.DIRECTION_DOWN;
|
|
|
|
return touch1.pageY - touch2.pageY > 0 ? ionic.Gestures.DIRECTION_UP : ionic.Gestures.DIRECTION_DOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
@ -698,7 +698,7 @@
|
|
|
|
* @returns {Boolean} is_vertical
|
|
|
|
* @returns {Boolean} is_vertical
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
isVertical: function isVertical(direction) {
|
|
|
|
isVertical: function isVertical(direction) {
|
|
|
|
return (direction == ion.Gestures.DIRECTION_UP || direction == ion.Gestures.DIRECTION_DOWN);
|
|
|
|
return (direction == ionic.Gestures.DIRECTION_UP || direction == ionic.Gestures.DIRECTION_DOWN);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -742,14 +742,14 @@
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ion.Gestures.detection = {
|
|
|
|
ionic.Gestures.detection = {
|
|
|
|
// contains all registred ion.Gestures.gestures in the correct order
|
|
|
|
// contains all registred ionic.Gestures.gestures in the correct order
|
|
|
|
gestures: [],
|
|
|
|
gestures: [],
|
|
|
|
|
|
|
|
|
|
|
|
// data of the current ion.Gestures.gesture detection session
|
|
|
|
// data of the current ionic.Gestures.gesture detection session
|
|
|
|
current: null,
|
|
|
|
current: null,
|
|
|
|
|
|
|
|
|
|
|
|
// the previous ion.Gestures.gesture session data
|
|
|
|
// the previous ionic.Gestures.gesture session data
|
|
|
|
// is a full clone of the previous gesture.current object
|
|
|
|
// is a full clone of the previous gesture.current object
|
|
|
|
previous: null,
|
|
|
|
previous: null,
|
|
|
|
|
|
|
|
|
|
|
|
@ -758,12 +758,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* start ion.Gestures.gesture detection
|
|
|
|
* start ionic.Gestures.gesture detection
|
|
|
|
* @param {ion.Gestures.Instance} inst
|
|
|
|
* @param {ionic.Gestures.Instance} inst
|
|
|
|
* @param {Object} eventData
|
|
|
|
* @param {Object} eventData
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
startDetect: function startDetect(inst, eventData) {
|
|
|
|
startDetect: function startDetect(inst, eventData) {
|
|
|
|
// already busy with a ion.Gestures.gesture detection on an element
|
|
|
|
// already busy with a ionic.Gestures.gesture detection on an element
|
|
|
|
if(this.current) {
|
|
|
|
if(this.current) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -771,8 +771,8 @@
|
|
|
|
this.stopped = false;
|
|
|
|
this.stopped = false;
|
|
|
|
|
|
|
|
|
|
|
|
this.current = {
|
|
|
|
this.current = {
|
|
|
|
inst : inst, // reference to ion.GesturesInstance we're working for
|
|
|
|
inst : inst, // reference to ionic.GesturesInstance we're working for
|
|
|
|
startEvent : ion.Gestures.utils.extend({}, eventData), // start eventData for distances, timing etc
|
|
|
|
startEvent : ionic.Gestures.utils.extend({}, eventData), // start eventData for distances, timing etc
|
|
|
|
lastEvent : false, // last eventData
|
|
|
|
lastEvent : false, // last eventData
|
|
|
|
name : '' // current gesture we're in/detected, can be 'tap', 'hold' etc
|
|
|
|
name : '' // current gesture we're in/detected, can be 'tap', 'hold' etc
|
|
|
|
};
|
|
|
|
};
|
|
|
|
@ -782,7 +782,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* ion.Gestures.gesture detection
|
|
|
|
* ionic.Gestures.gesture detection
|
|
|
|
* @param {Object} eventData
|
|
|
|
* @param {Object} eventData
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
detect: function detect(eventData) {
|
|
|
|
detect: function detect(eventData) {
|
|
|
|
@ -796,7 +796,7 @@
|
|
|
|
// instance options
|
|
|
|
// instance options
|
|
|
|
var inst_options = this.current.inst.options;
|
|
|
|
var inst_options = this.current.inst.options;
|
|
|
|
|
|
|
|
|
|
|
|
// call ion.Gestures.gesture handlers
|
|
|
|
// call ionic.Gestures.gesture handlers
|
|
|
|
for(var g=0,len=this.gestures.length; g<len; g++) {
|
|
|
|
for(var g=0,len=this.gestures.length; g<len; g++) {
|
|
|
|
var gesture = this.gestures[g];
|
|
|
|
var gesture = this.gestures[g];
|
|
|
|
|
|
|
|
|
|
|
|
@ -816,7 +816,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// endevent, but not the last touch, so dont stop
|
|
|
|
// endevent, but not the last touch, so dont stop
|
|
|
|
if(eventData.eventType == ion.Gestures.EVENT_END && !eventData.touches.length-1) {
|
|
|
|
if(eventData.eventType == ionic.Gestures.EVENT_END && !eventData.touches.length-1) {
|
|
|
|
this.stopDetect();
|
|
|
|
this.stopDetect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -825,14 +825,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* clear the ion.Gestures.gesture vars
|
|
|
|
* clear the ionic.Gestures.gesture vars
|
|
|
|
* this is called on endDetect, but can also be used when a final ion.Gestures.gesture has been detected
|
|
|
|
* this is called on endDetect, but can also be used when a final ionic.Gestures.gesture has been detected
|
|
|
|
* to stop other ion.Gestures.gestures from being fired
|
|
|
|
* to stop other ionic.Gestures.gestures from being fired
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
stopDetect: function stopDetect() {
|
|
|
|
stopDetect: function stopDetect() {
|
|
|
|
// clone current data to the store as the previous gesture
|
|
|
|
// clone current data to the store as the previous gesture
|
|
|
|
// used for the double tap gesture, since this is an other gesture detect session
|
|
|
|
// used for the double tap gesture, since this is an other gesture detect session
|
|
|
|
this.previous = ion.Gestures.utils.extend({}, this.current);
|
|
|
|
this.previous = ionic.Gestures.utils.extend({}, this.current);
|
|
|
|
|
|
|
|
|
|
|
|
// reset the current
|
|
|
|
// reset the current
|
|
|
|
this.current = null;
|
|
|
|
this.current = null;
|
|
|
|
@ -843,7 +843,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* extend eventData for ion.Gestures.gestures
|
|
|
|
* extend eventData for ionic.Gestures.gestures
|
|
|
|
* @param {Object} ev
|
|
|
|
* @param {Object} ev
|
|
|
|
* @returns {Object} ev
|
|
|
|
* @returns {Object} ev
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ -858,16 +858,16 @@
|
|
|
|
// extend 1 level deep to get the touchlist with the touch objects
|
|
|
|
// extend 1 level deep to get the touchlist with the touch objects
|
|
|
|
startEv.touches = [];
|
|
|
|
startEv.touches = [];
|
|
|
|
for(var i=0,len=ev.touches.length; i<len; i++) {
|
|
|
|
for(var i=0,len=ev.touches.length; i<len; i++) {
|
|
|
|
startEv.touches.push(ion.Gestures.utils.extend({}, ev.touches[i]));
|
|
|
|
startEv.touches.push(ionic.Gestures.utils.extend({}, ev.touches[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var delta_time = ev.timeStamp - startEv.timeStamp,
|
|
|
|
var delta_time = ev.timeStamp - startEv.timeStamp,
|
|
|
|
delta_x = ev.center.pageX - startEv.center.pageX,
|
|
|
|
delta_x = ev.center.pageX - startEv.center.pageX,
|
|
|
|
delta_y = ev.center.pageY - startEv.center.pageY,
|
|
|
|
delta_y = ev.center.pageY - startEv.center.pageY,
|
|
|
|
velocity = ion.Gestures.utils.getVelocity(delta_time, delta_x, delta_y);
|
|
|
|
velocity = ionic.Gestures.utils.getVelocity(delta_time, delta_x, delta_y);
|
|
|
|
|
|
|
|
|
|
|
|
ion.Gestures.utils.extend(ev, {
|
|
|
|
ionic.Gestures.utils.extend(ev, {
|
|
|
|
deltaTime : delta_time,
|
|
|
|
deltaTime : delta_time,
|
|
|
|
|
|
|
|
|
|
|
|
deltaX : delta_x,
|
|
|
|
deltaX : delta_x,
|
|
|
|
@ -876,12 +876,12 @@
|
|
|
|
velocityX : velocity.x,
|
|
|
|
velocityX : velocity.x,
|
|
|
|
velocityY : velocity.y,
|
|
|
|
velocityY : velocity.y,
|
|
|
|
|
|
|
|
|
|
|
|
distance : ion.Gestures.utils.getDistance(startEv.center, ev.center),
|
|
|
|
distance : ionic.Gestures.utils.getDistance(startEv.center, ev.center),
|
|
|
|
angle : ion.Gestures.utils.getAngle(startEv.center, ev.center),
|
|
|
|
angle : ionic.Gestures.utils.getAngle(startEv.center, ev.center),
|
|
|
|
direction : ion.Gestures.utils.getDirection(startEv.center, ev.center),
|
|
|
|
direction : ionic.Gestures.utils.getDirection(startEv.center, ev.center),
|
|
|
|
|
|
|
|
|
|
|
|
scale : ion.Gestures.utils.getScale(startEv.touches, ev.touches),
|
|
|
|
scale : ionic.Gestures.utils.getScale(startEv.touches, ev.touches),
|
|
|
|
rotation : ion.Gestures.utils.getRotation(startEv.touches, ev.touches),
|
|
|
|
rotation : ionic.Gestures.utils.getRotation(startEv.touches, ev.touches),
|
|
|
|
|
|
|
|
|
|
|
|
startEvent : startEv
|
|
|
|
startEvent : startEv
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -902,13 +902,13 @@
|
|
|
|
options[gesture.name] = true;
|
|
|
|
options[gesture.name] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// extend ion.Gestures default options with the ion.Gestures.gesture options
|
|
|
|
// extend ionic.Gestures default options with the ionic.Gestures.gesture options
|
|
|
|
ion.Gestures.utils.extend(ion.Gestures.defaults, options, true);
|
|
|
|
ionic.Gestures.utils.extend(ionic.Gestures.defaults, options, true);
|
|
|
|
|
|
|
|
|
|
|
|
// set its index
|
|
|
|
// set its index
|
|
|
|
gesture.index = gesture.index || 1000;
|
|
|
|
gesture.index = gesture.index || 1000;
|
|
|
|
|
|
|
|
|
|
|
|
// add ion.Gestures.gesture to the list
|
|
|
|
// add ionic.Gestures.gesture to the list
|
|
|
|
this.gestures.push(gesture);
|
|
|
|
this.gestures.push(gesture);
|
|
|
|
|
|
|
|
|
|
|
|
// sort the list by index
|
|
|
|
// sort the list by index
|
|
|
|
@ -927,7 +927,7 @@
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ion.Gestures.gestures = ion.Gestures.gestures || {};
|
|
|
|
ionic.Gestures.gestures = ionic.Gestures.gestures || {};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Custom gestures
|
|
|
|
* Custom gestures
|
|
|
|
@ -971,7 +971,7 @@
|
|
|
|
* timeStamp {Number} time the event occurred
|
|
|
|
* timeStamp {Number} time the event occurred
|
|
|
|
* target {HTMLElement} target element
|
|
|
|
* target {HTMLElement} target element
|
|
|
|
* touches {Array} touches (fingers, pointers, mouse) on the screen
|
|
|
|
* touches {Array} touches (fingers, pointers, mouse) on the screen
|
|
|
|
* pointerType {String} kind of pointer that was used. matches ion.Gestures.POINTER_MOUSE|TOUCH
|
|
|
|
* pointerType {String} kind of pointer that was used. matches ionic.Gestures.POINTER_MOUSE|TOUCH
|
|
|
|
* center {Object} center position of the touches. contains pageX and pageY
|
|
|
|
* center {Object} center position of the touches. contains pageX and pageY
|
|
|
|
* deltaTime {Number} the total time of the touches in the screen
|
|
|
|
* deltaTime {Number} the total time of the touches in the screen
|
|
|
|
* deltaX {Number} the delta on x axis we haved moved
|
|
|
|
* deltaX {Number} the delta on x axis we haved moved
|
|
|
|
@ -979,46 +979,46 @@
|
|
|
|
* velocityX {Number} the velocity on the x
|
|
|
|
* velocityX {Number} the velocity on the x
|
|
|
|
* velocityY {Number} the velocity on y
|
|
|
|
* velocityY {Number} the velocity on y
|
|
|
|
* angle {Number} the angle we are moving
|
|
|
|
* angle {Number} the angle we are moving
|
|
|
|
* direction {String} the direction we are moving. matches ion.Gestures.DIRECTION_UP|DOWN|LEFT|RIGHT
|
|
|
|
* direction {String} the direction we are moving. matches ionic.Gestures.DIRECTION_UP|DOWN|LEFT|RIGHT
|
|
|
|
* distance {Number} the distance we haved moved
|
|
|
|
* distance {Number} the distance we haved moved
|
|
|
|
* scale {Number} scaling of the touches, needs 2 touches
|
|
|
|
* scale {Number} scaling of the touches, needs 2 touches
|
|
|
|
* rotation {Number} rotation of the touches, needs 2 touches *
|
|
|
|
* rotation {Number} rotation of the touches, needs 2 touches *
|
|
|
|
* eventType {String} matches ion.Gestures.EVENT_START|MOVE|END
|
|
|
|
* eventType {String} matches ionic.Gestures.EVENT_START|MOVE|END
|
|
|
|
* srcEvent {Object} the source event, like TouchStart or MouseDown *
|
|
|
|
* srcEvent {Object} the source event, like TouchStart or MouseDown *
|
|
|
|
* startEvent {Object} contains the same properties as above,
|
|
|
|
* startEvent {Object} contains the same properties as above,
|
|
|
|
* but from the first touch. this is used to calculate
|
|
|
|
* but from the first touch. this is used to calculate
|
|
|
|
* distances, deltaTime, scaling etc
|
|
|
|
* distances, deltaTime, scaling etc
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param {ion.Gestures.Instance} inst
|
|
|
|
* @param {ionic.Gestures.Instance} inst
|
|
|
|
* the instance we are doing the detection for. you can get the options from
|
|
|
|
* the instance we are doing the detection for. you can get the options from
|
|
|
|
* the inst.options object and trigger the gesture event by calling inst.trigger
|
|
|
|
* the inst.options object and trigger the gesture event by calling inst.trigger
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Handle gestures
|
|
|
|
* Handle gestures
|
|
|
|
* --------------------
|
|
|
|
* --------------------
|
|
|
|
* inside the handler you can get/set ion.Gestures.detection.current. This is the current
|
|
|
|
* inside the handler you can get/set ionic.Gestures.detectionic.current. This is the current
|
|
|
|
* detection session. It has the following properties
|
|
|
|
* detection sessionic. It has the following properties
|
|
|
|
* @param {String} name
|
|
|
|
* @param {String} name
|
|
|
|
* contains the name of the gesture we have detected. it has not a real function,
|
|
|
|
* contains the name of the gesture we have detected. it has not a real function,
|
|
|
|
* only to check in other gestures if something is detected.
|
|
|
|
* only to check in other gestures if something is detected.
|
|
|
|
* like in the drag gesture we set it to 'drag' and in the swipe gesture we can
|
|
|
|
* like in the drag gesture we set it to 'drag' and in the swipe gesture we can
|
|
|
|
* check if the current gesture is 'drag' by accessing ion.Gestures.detection.current.name
|
|
|
|
* check if the current gesture is 'drag' by accessing ionic.Gestures.detectionic.current.name
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @readonly
|
|
|
|
* @readonly
|
|
|
|
* @param {ion.Gestures.Instance} inst
|
|
|
|
* @param {ionic.Gestures.Instance} inst
|
|
|
|
* the instance we do the detection for
|
|
|
|
* the instance we do the detection for
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @readonly
|
|
|
|
* @readonly
|
|
|
|
* @param {Object} startEvent
|
|
|
|
* @param {Object} startEvent
|
|
|
|
* contains the properties of the first gesture detection in this session.
|
|
|
|
* contains the properties of the first gesture detection in this sessionic.
|
|
|
|
* Used for calculations about timing, distance, etc.
|
|
|
|
* Used for calculations about timing, distance, etc.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @readonly
|
|
|
|
* @readonly
|
|
|
|
* @param {Object} lastEvent
|
|
|
|
* @param {Object} lastEvent
|
|
|
|
* contains all the properties of the last gesture detect in this session.
|
|
|
|
* contains all the properties of the last gesture detect in this sessionic.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* after the gesture detection session has been completed (user has released the screen)
|
|
|
|
* after the gesture detection session has been completed (user has released the screen)
|
|
|
|
* the ion.Gestures.detection.current object is copied into ion.Gestures.detection.previous,
|
|
|
|
* the ionic.Gestures.detectionic.current object is copied into ionic.Gestures.detectionic.previous,
|
|
|
|
* this is usefull for gestures like doubletap, where you need to know if the
|
|
|
|
* this is usefull for gestures like doubletap, where you need to know if the
|
|
|
|
* previous gesture was a tap
|
|
|
|
* previous gesture was a tap
|
|
|
|
*
|
|
|
|
*
|
|
|
|
@ -1030,8 +1030,8 @@
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Register gestures
|
|
|
|
* Register gestures
|
|
|
|
* --------------------
|
|
|
|
* --------------------
|
|
|
|
* When an gesture is added to the ion.Gestures.gestures object, it is auto registered
|
|
|
|
* When an gesture is added to the ionic.Gestures.gestures object, it is auto registered
|
|
|
|
* at the setup of the first ion.Gestures instance. You can also call ion.Gestures.detection.register
|
|
|
|
* at the setup of the first ionic.Gestures instance. You can also call ionic.Gestures.detectionic.register
|
|
|
|
* manually and pass your gesture object as a param
|
|
|
|
* manually and pass your gesture object as a param
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ -1041,7 +1041,7 @@
|
|
|
|
* Touch stays at the same place for x time
|
|
|
|
* Touch stays at the same place for x time
|
|
|
|
* @events hold
|
|
|
|
* @events hold
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
ion.Gestures.gestures.Hold = {
|
|
|
|
ionic.Gestures.gestures.Hold = {
|
|
|
|
name: 'hold',
|
|
|
|
name: 'hold',
|
|
|
|
index: 10,
|
|
|
|
index: 10,
|
|
|
|
defaults: {
|
|
|
|
defaults: {
|
|
|
|
@ -1051,30 +1051,30 @@
|
|
|
|
timer: null,
|
|
|
|
timer: null,
|
|
|
|
handler: function holdGesture(ev, inst) {
|
|
|
|
handler: function holdGesture(ev, inst) {
|
|
|
|
switch(ev.eventType) {
|
|
|
|
switch(ev.eventType) {
|
|
|
|
case ion.Gestures.EVENT_START:
|
|
|
|
case ionic.Gestures.EVENT_START:
|
|
|
|
// clear any running timers
|
|
|
|
// clear any running timers
|
|
|
|
clearTimeout(this.timer);
|
|
|
|
clearTimeout(this.timer);
|
|
|
|
|
|
|
|
|
|
|
|
// set the gesture so we can check in the timeout if it still is
|
|
|
|
// set the gesture so we can check in the timeout if it still is
|
|
|
|
ion.Gestures.detection.current.name = this.name;
|
|
|
|
ionic.Gestures.detection.current.name = this.name;
|
|
|
|
|
|
|
|
|
|
|
|
// set timer and if after the timeout it still is hold,
|
|
|
|
// set timer and if after the timeout it still is hold,
|
|
|
|
// we trigger the hold event
|
|
|
|
// we trigger the hold event
|
|
|
|
this.timer = setTimeout(function() {
|
|
|
|
this.timer = setTimeout(function() {
|
|
|
|
if(ion.Gestures.detection.current.name == 'hold') {
|
|
|
|
if(ionic.Gestures.detection.current.name == 'hold') {
|
|
|
|
inst.trigger('hold', ev);
|
|
|
|
inst.trigger('hold', ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, inst.options.hold_timeout);
|
|
|
|
}, inst.options.hold_timeout);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
// when you move or end we clear the timer
|
|
|
|
// when you move or end we clear the timer
|
|
|
|
case ion.Gestures.EVENT_MOVE:
|
|
|
|
case ionic.Gestures.EVENT_MOVE:
|
|
|
|
if(ev.distance > inst.options.hold_threshold) {
|
|
|
|
if(ev.distance > inst.options.hold_threshold) {
|
|
|
|
clearTimeout(this.timer);
|
|
|
|
clearTimeout(this.timer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case ion.Gestures.EVENT_END:
|
|
|
|
case ionic.Gestures.EVENT_END:
|
|
|
|
clearTimeout(this.timer);
|
|
|
|
clearTimeout(this.timer);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1087,7 +1087,7 @@
|
|
|
|
* Quick touch at a place or double at the same place
|
|
|
|
* Quick touch at a place or double at the same place
|
|
|
|
* @events tap, doubletap
|
|
|
|
* @events tap, doubletap
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
ion.Gestures.gestures.Tap = {
|
|
|
|
ionic.Gestures.gestures.Tap = {
|
|
|
|
name: 'tap',
|
|
|
|
name: 'tap',
|
|
|
|
index: 100,
|
|
|
|
index: 100,
|
|
|
|
defaults: {
|
|
|
|
defaults: {
|
|
|
|
@ -1098,9 +1098,9 @@
|
|
|
|
doubletap_interval : 300
|
|
|
|
doubletap_interval : 300
|
|
|
|
},
|
|
|
|
},
|
|
|
|
handler: function tapGesture(ev, inst) {
|
|
|
|
handler: function tapGesture(ev, inst) {
|
|
|
|
if(ev.eventType == ion.Gestures.EVENT_END) {
|
|
|
|
if(ev.eventType == ionic.Gestures.EVENT_END) {
|
|
|
|
// previous gesture, for the double tap since these are two different gesture detections
|
|
|
|
// previous gesture, for the double tap since these are two different gesture detections
|
|
|
|
var prev = ion.Gestures.detection.previous,
|
|
|
|
var prev = ionic.Gestures.detection.previous,
|
|
|
|
did_doubletap = false;
|
|
|
|
did_doubletap = false;
|
|
|
|
|
|
|
|
|
|
|
|
// when the touchtime is higher then the max touch time
|
|
|
|
// when the touchtime is higher then the max touch time
|
|
|
|
@ -1120,8 +1120,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
// do a single tap
|
|
|
|
// do a single tap
|
|
|
|
if(!did_doubletap || inst.options.tap_always) {
|
|
|
|
if(!did_doubletap || inst.options.tap_always) {
|
|
|
|
ion.Gestures.detection.current.name = 'tap';
|
|
|
|
ionic.Gestures.detection.current.name = 'tap';
|
|
|
|
inst.trigger(ion.Gestures.detection.current.name, ev);
|
|
|
|
inst.trigger(ionic.Gestures.detection.current.name, ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1133,7 +1133,7 @@
|
|
|
|
* triggers swipe events when the end velocity is above the threshold
|
|
|
|
* triggers swipe events when the end velocity is above the threshold
|
|
|
|
* @events swipe, swipeleft, swiperight, swipeup, swipedown
|
|
|
|
* @events swipe, swipeleft, swiperight, swipeup, swipedown
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
ion.Gestures.gestures.Swipe = {
|
|
|
|
ionic.Gestures.gestures.Swipe = {
|
|
|
|
name: 'swipe',
|
|
|
|
name: 'swipe',
|
|
|
|
index: 40,
|
|
|
|
index: 40,
|
|
|
|
defaults: {
|
|
|
|
defaults: {
|
|
|
|
@ -1142,7 +1142,7 @@
|
|
|
|
swipe_velocity : 0.7
|
|
|
|
swipe_velocity : 0.7
|
|
|
|
},
|
|
|
|
},
|
|
|
|
handler: function swipeGesture(ev, inst) {
|
|
|
|
handler: function swipeGesture(ev, inst) {
|
|
|
|
if(ev.eventType == ion.Gestures.EVENT_END) {
|
|
|
|
if(ev.eventType == ionic.Gestures.EVENT_END) {
|
|
|
|
// max touches
|
|
|
|
// max touches
|
|
|
|
if(inst.options.swipe_max_touches > 0 &&
|
|
|
|
if(inst.options.swipe_max_touches > 0 &&
|
|
|
|
ev.touches.length > inst.options.swipe_max_touches) {
|
|
|
|
ev.touches.length > inst.options.swipe_max_touches) {
|
|
|
|
@ -1169,7 +1169,7 @@
|
|
|
|
* you disable scrolling on that area.
|
|
|
|
* you disable scrolling on that area.
|
|
|
|
* @events drag, drapleft, dragright, dragup, dragdown
|
|
|
|
* @events drag, drapleft, dragright, dragup, dragdown
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
ion.Gestures.gestures.Drag = {
|
|
|
|
ionic.Gestures.gestures.Drag = {
|
|
|
|
name: 'drag',
|
|
|
|
name: 'drag',
|
|
|
|
index: 50,
|
|
|
|
index: 50,
|
|
|
|
defaults: {
|
|
|
|
defaults: {
|
|
|
|
@ -1197,7 +1197,7 @@
|
|
|
|
handler: function dragGesture(ev, inst) {
|
|
|
|
handler: function dragGesture(ev, inst) {
|
|
|
|
// current gesture isnt drag, but dragged is true
|
|
|
|
// current gesture isnt drag, but dragged is true
|
|
|
|
// this means an other gesture is busy. now call dragend
|
|
|
|
// this means an other gesture is busy. now call dragend
|
|
|
|
if(ion.Gestures.detection.current.name != this.name && this.triggered) {
|
|
|
|
if(ionic.Gestures.detection.current.name != this.name && this.triggered) {
|
|
|
|
inst.trigger(this.name +'end', ev);
|
|
|
|
inst.trigger(this.name +'end', ev);
|
|
|
|
this.triggered = false;
|
|
|
|
this.triggered = false;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
@ -1210,46 +1210,46 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(ev.eventType) {
|
|
|
|
switch(ev.eventType) {
|
|
|
|
case ion.Gestures.EVENT_START:
|
|
|
|
case ionic.Gestures.EVENT_START:
|
|
|
|
this.triggered = false;
|
|
|
|
this.triggered = false;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case ion.Gestures.EVENT_MOVE:
|
|
|
|
case ionic.Gestures.EVENT_MOVE:
|
|
|
|
// when the distance we moved is too small we skip this gesture
|
|
|
|
// when the distance we moved is too small we skip this gesture
|
|
|
|
// or we can be already in dragging
|
|
|
|
// or we can be already in dragging
|
|
|
|
if(ev.distance < inst.options.drag_min_distance &&
|
|
|
|
if(ev.distance < inst.options.drag_min_distance &&
|
|
|
|
ion.Gestures.detection.current.name != this.name) {
|
|
|
|
ionic.Gestures.detection.current.name != this.name) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// we are dragging!
|
|
|
|
// we are dragging!
|
|
|
|
if(ion.Gestures.detection.current.name != this.name) {
|
|
|
|
if(ionic.Gestures.detection.current.name != this.name) {
|
|
|
|
ion.Gestures.detection.current.name = this.name;
|
|
|
|
ionic.Gestures.detection.current.name = this.name;
|
|
|
|
if (inst.options.correct_for_drag_min_distance) {
|
|
|
|
if (inst.options.correct_for_drag_min_distance) {
|
|
|
|
// When a drag is triggered, set the event center to drag_min_distance pixels from the original event center.
|
|
|
|
// When a drag is triggered, set the event center to drag_min_distance pixels from the original event center.
|
|
|
|
// Without this correction, the dragged distance would jumpstart at drag_min_distance pixels instead of at 0.
|
|
|
|
// Without this correction, the dragged distance would jumpstart at drag_min_distance pixels instead of at 0.
|
|
|
|
// It might be useful to save the original start point somewhere
|
|
|
|
// It might be useful to save the original start point somewhere
|
|
|
|
var factor = Math.abs(inst.options.drag_min_distance/ev.distance);
|
|
|
|
var factor = Math.abs(inst.options.drag_min_distance/ev.distance);
|
|
|
|
ion.Gestures.detection.current.startEvent.center.pageX += ev.deltaX * factor;
|
|
|
|
ionic.Gestures.detection.current.startEvent.center.pageX += ev.deltaX * factor;
|
|
|
|
ion.Gestures.detection.current.startEvent.center.pageY += ev.deltaY * factor;
|
|
|
|
ionic.Gestures.detection.current.startEvent.center.pageY += ev.deltaY * factor;
|
|
|
|
|
|
|
|
|
|
|
|
// recalculate event data using new start point
|
|
|
|
// recalculate event data using new start point
|
|
|
|
ev = ion.Gestures.detection.extendEventData(ev);
|
|
|
|
ev = ionic.Gestures.detection.extendEventData(ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// lock drag to axis?
|
|
|
|
// lock drag to axis?
|
|
|
|
if(ion.Gestures.detection.current.lastEvent.drag_locked_to_axis || (inst.options.drag_lock_to_axis && inst.options.drag_lock_min_distance<=ev.distance)) {
|
|
|
|
if(ionic.Gestures.detection.current.lastEvent.drag_locked_to_axis || (inst.options.drag_lock_to_axis && inst.options.drag_lock_min_distance<=ev.distance)) {
|
|
|
|
ev.drag_locked_to_axis = true;
|
|
|
|
ev.drag_locked_to_axis = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var last_direction = ion.Gestures.detection.current.lastEvent.direction;
|
|
|
|
var last_direction = ionic.Gestures.detection.current.lastEvent.direction;
|
|
|
|
if(ev.drag_locked_to_axis && last_direction !== ev.direction) {
|
|
|
|
if(ev.drag_locked_to_axis && last_direction !== ev.direction) {
|
|
|
|
// keep direction on the axis that the drag gesture started on
|
|
|
|
// keep direction on the axis that the drag gesture started on
|
|
|
|
if(ion.Gestures.utils.isVertical(last_direction)) {
|
|
|
|
if(ionic.Gestures.utils.isVertical(last_direction)) {
|
|
|
|
ev.direction = (ev.deltaY < 0) ? ion.Gestures.DIRECTION_UP : ion.Gestures.DIRECTION_DOWN;
|
|
|
|
ev.direction = (ev.deltaY < 0) ? ionic.Gestures.DIRECTION_UP : ionic.Gestures.DIRECTION_DOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
ev.direction = (ev.deltaX < 0) ? ion.Gestures.DIRECTION_LEFT : ion.Gestures.DIRECTION_RIGHT;
|
|
|
|
ev.direction = (ev.deltaX < 0) ? ionic.Gestures.DIRECTION_LEFT : ionic.Gestures.DIRECTION_RIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1266,13 +1266,13 @@
|
|
|
|
inst.trigger(this.name + ev.direction, ev);
|
|
|
|
inst.trigger(this.name + ev.direction, ev);
|
|
|
|
|
|
|
|
|
|
|
|
// block the browser events
|
|
|
|
// block the browser events
|
|
|
|
if( (inst.options.drag_block_vertical && ion.Gestures.utils.isVertical(ev.direction)) ||
|
|
|
|
if( (inst.options.drag_block_vertical && ionic.Gestures.utils.isVertical(ev.direction)) ||
|
|
|
|
(inst.options.drag_block_horizontal && !ion.Gestures.utils.isVertical(ev.direction))) {
|
|
|
|
(inst.options.drag_block_horizontal && !ionic.Gestures.utils.isVertical(ev.direction))) {
|
|
|
|
ev.preventDefault();
|
|
|
|
ev.preventDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case ion.Gestures.EVENT_END:
|
|
|
|
case ionic.Gestures.EVENT_END:
|
|
|
|
// trigger dragend
|
|
|
|
// trigger dragend
|
|
|
|
if(this.triggered) {
|
|
|
|
if(this.triggered) {
|
|
|
|
inst.trigger(this.name +'end', ev);
|
|
|
|
inst.trigger(this.name +'end', ev);
|
|
|
|
@ -1290,7 +1290,7 @@
|
|
|
|
* User want to scale or rotate with 2 fingers
|
|
|
|
* User want to scale or rotate with 2 fingers
|
|
|
|
* @events transform, pinch, pinchin, pinchout, rotate
|
|
|
|
* @events transform, pinch, pinchin, pinchout, rotate
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
ion.Gestures.gestures.Transform = {
|
|
|
|
ionic.Gestures.gestures.Transform = {
|
|
|
|
name: 'transform',
|
|
|
|
name: 'transform',
|
|
|
|
index: 45,
|
|
|
|
index: 45,
|
|
|
|
defaults: {
|
|
|
|
defaults: {
|
|
|
|
@ -1307,7 +1307,7 @@
|
|
|
|
handler: function transformGesture(ev, inst) {
|
|
|
|
handler: function transformGesture(ev, inst) {
|
|
|
|
// current gesture isnt drag, but dragged is true
|
|
|
|
// current gesture isnt drag, but dragged is true
|
|
|
|
// this means an other gesture is busy. now call dragend
|
|
|
|
// this means an other gesture is busy. now call dragend
|
|
|
|
if(ion.Gestures.detection.current.name != this.name && this.triggered) {
|
|
|
|
if(ionic.Gestures.detection.current.name != this.name && this.triggered) {
|
|
|
|
inst.trigger(this.name +'end', ev);
|
|
|
|
inst.trigger(this.name +'end', ev);
|
|
|
|
this.triggered = false;
|
|
|
|
this.triggered = false;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
@ -1324,11 +1324,11 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch(ev.eventType) {
|
|
|
|
switch(ev.eventType) {
|
|
|
|
case ion.Gestures.EVENT_START:
|
|
|
|
case ionic.Gestures.EVENT_START:
|
|
|
|
this.triggered = false;
|
|
|
|
this.triggered = false;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case ion.Gestures.EVENT_MOVE:
|
|
|
|
case ionic.Gestures.EVENT_MOVE:
|
|
|
|
var scale_threshold = Math.abs(1-ev.scale);
|
|
|
|
var scale_threshold = Math.abs(1-ev.scale);
|
|
|
|
var rotation_threshold = Math.abs(ev.rotation);
|
|
|
|
var rotation_threshold = Math.abs(ev.rotation);
|
|
|
|
|
|
|
|
|
|
|
|
@ -1340,7 +1340,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// we are transforming!
|
|
|
|
// we are transforming!
|
|
|
|
ion.Gestures.detection.current.name = this.name;
|
|
|
|
ionic.Gestures.detection.current.name = this.name;
|
|
|
|
|
|
|
|
|
|
|
|
// first time, trigger dragstart event
|
|
|
|
// first time, trigger dragstart event
|
|
|
|
if(!this.triggered) {
|
|
|
|
if(!this.triggered) {
|
|
|
|
@ -1362,7 +1362,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case ion.Gestures.EVENT_END:
|
|
|
|
case ionic.Gestures.EVENT_END:
|
|
|
|
// trigger dragend
|
|
|
|
// trigger dragend
|
|
|
|
if(this.triggered) {
|
|
|
|
if(this.triggered) {
|
|
|
|
inst.trigger(this.name +'end', ev);
|
|
|
|
inst.trigger(this.name +'end', ev);
|
|
|
|
@ -1380,7 +1380,7 @@
|
|
|
|
* Called as first, tells the user has touched the screen
|
|
|
|
* Called as first, tells the user has touched the screen
|
|
|
|
* @events touch
|
|
|
|
* @events touch
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
ion.Gestures.gestures.Touch = {
|
|
|
|
ionic.Gestures.gestures.Touch = {
|
|
|
|
name: 'touch',
|
|
|
|
name: 'touch',
|
|
|
|
index: -Infinity,
|
|
|
|
index: -Infinity,
|
|
|
|
defaults: {
|
|
|
|
defaults: {
|
|
|
|
@ -1395,7 +1395,7 @@
|
|
|
|
prevent_mouseevents: false
|
|
|
|
prevent_mouseevents: false
|
|
|
|
},
|
|
|
|
},
|
|
|
|
handler: function touchGesture(ev, inst) {
|
|
|
|
handler: function touchGesture(ev, inst) {
|
|
|
|
if(inst.options.prevent_mouseevents && ev.pointerType == ion.Gestures.POINTER_MOUSE) {
|
|
|
|
if(inst.options.prevent_mouseevents && ev.pointerType == ionic.Gestures.POINTER_MOUSE) {
|
|
|
|
ev.stopDetect();
|
|
|
|
ev.stopDetect();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1404,7 +1404,7 @@
|
|
|
|
ev.preventDefault();
|
|
|
|
ev.preventDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(ev.eventType == ion.Gestures.EVENT_START) {
|
|
|
|
if(ev.eventType == ionic.Gestures.EVENT_START) {
|
|
|
|
inst.trigger(this.name, ev);
|
|
|
|
inst.trigger(this.name, ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1416,13 +1416,13 @@
|
|
|
|
* Called as last, tells the user has released the screen
|
|
|
|
* Called as last, tells the user has released the screen
|
|
|
|
* @events release
|
|
|
|
* @events release
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
ion.Gestures.gestures.Release = {
|
|
|
|
ionic.Gestures.gestures.Release = {
|
|
|
|
name: 'release',
|
|
|
|
name: 'release',
|
|
|
|
index: Infinity,
|
|
|
|
index: Infinity,
|
|
|
|
handler: function releaseGesture(ev, inst) {
|
|
|
|
handler: function releaseGesture(ev, inst) {
|
|
|
|
if(ev.eventType == ion.Gestures.EVENT_END) {
|
|
|
|
if(ev.eventType == ionic.Gestures.EVENT_END) {
|
|
|
|
inst.trigger(this.name, ev);
|
|
|
|
inst.trigger(this.name, ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})(this, document, ion = this.ion || {});
|
|
|
|
})(this, document, ionic = this.ionic || {});
|
|
|
|
|