mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 15:07:13 +08:00
39
dist/ionic.js
vendored
39
dist/ionic.js
vendored
@ -2444,6 +2444,7 @@ ionic.controllers.NavController.prototype = {
|
|||||||
this.left = options.left;
|
this.left = options.left;
|
||||||
this.right = options.right;
|
this.right = options.right;
|
||||||
this.content = options.content;
|
this.content = options.content;
|
||||||
|
this.dragThresholdX = options.dragThresholdX || 10;
|
||||||
|
|
||||||
this._rightShowing = false;
|
this._rightShowing = false;
|
||||||
this._leftShowing = false;
|
this._leftShowing = false;
|
||||||
@ -2661,33 +2662,37 @@ ionic.controllers.NavController.prototype = {
|
|||||||
// End a drag with the given event
|
// End a drag with the given event
|
||||||
_endDrag: function(e) {
|
_endDrag: function(e) {
|
||||||
this.snapToRest(e);
|
this.snapToRest(e);
|
||||||
|
this._startX = null;
|
||||||
|
this._lastX = null;
|
||||||
|
this._offsetX = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Initialize a drag with the given event
|
|
||||||
_initDrag: function(e) {
|
|
||||||
this.content.disableAnimation();
|
|
||||||
this._isDragging = true;
|
|
||||||
this._startX = 0;
|
|
||||||
this._offsetX = 0;
|
|
||||||
this._lastX = 0;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Handle a drag event
|
// Handle a drag event
|
||||||
_handleDrag: function(e) {
|
_handleDrag: function(e) {
|
||||||
if(!this._isDragging) {
|
// If we don't have start coords, grab and store them
|
||||||
this._initDrag(e);
|
if(!this._startX) {
|
||||||
|
|
||||||
this._startX = e.gesture.touches[0].pageX;
|
this._startX = e.gesture.touches[0].pageX;
|
||||||
this._lastX = this._startX;
|
this._lastX = this._startX;
|
||||||
|
} else {
|
||||||
|
// Grab the current tap coords
|
||||||
|
this._lastX = e.gesture.touches[0].pageX;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate difference from the tap points
|
||||||
|
if(Math.abs(this._lastX - this._startX) > this.dragThresholdX) {
|
||||||
|
// if the difference is greater than threshold, start dragging using the current
|
||||||
|
// point as the starting point
|
||||||
|
this._startX = this._lastX
|
||||||
|
|
||||||
|
this._isDragging = true;
|
||||||
|
// Initialize dragging
|
||||||
|
this.content.disableAnimation();
|
||||||
this._offsetX = this.getOpenAmount();
|
this._offsetX = this.getOpenAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
var newX = this._offsetX + (this._lastX - this._startX);
|
if(this._isDragging) {
|
||||||
|
this.openAmount(this._offsetX + (this._lastX - this._startX));
|
||||||
this.openAmount(newX);
|
}
|
||||||
|
|
||||||
this._lastX = e.gesture.touches[0].pageX;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
this.left = options.left;
|
this.left = options.left;
|
||||||
this.right = options.right;
|
this.right = options.right;
|
||||||
this.content = options.content;
|
this.content = options.content;
|
||||||
|
this.dragThresholdX = options.dragThresholdX || 10;
|
||||||
|
|
||||||
this._rightShowing = false;
|
this._rightShowing = false;
|
||||||
this._leftShowing = false;
|
this._leftShowing = false;
|
||||||
@ -229,33 +230,37 @@
|
|||||||
// End a drag with the given event
|
// End a drag with the given event
|
||||||
_endDrag: function(e) {
|
_endDrag: function(e) {
|
||||||
this.snapToRest(e);
|
this.snapToRest(e);
|
||||||
|
this._startX = null;
|
||||||
|
this._lastX = null;
|
||||||
|
this._offsetX = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Initialize a drag with the given event
|
|
||||||
_initDrag: function(e) {
|
|
||||||
this.content.disableAnimation();
|
|
||||||
this._isDragging = true;
|
|
||||||
this._startX = 0;
|
|
||||||
this._offsetX = 0;
|
|
||||||
this._lastX = 0;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Handle a drag event
|
// Handle a drag event
|
||||||
_handleDrag: function(e) {
|
_handleDrag: function(e) {
|
||||||
if(!this._isDragging) {
|
// If we don't have start coords, grab and store them
|
||||||
this._initDrag(e);
|
if(!this._startX) {
|
||||||
|
|
||||||
this._startX = e.gesture.touches[0].pageX;
|
this._startX = e.gesture.touches[0].pageX;
|
||||||
this._lastX = this._startX;
|
this._lastX = this._startX;
|
||||||
|
} else {
|
||||||
|
// Grab the current tap coords
|
||||||
|
this._lastX = e.gesture.touches[0].pageX;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate difference from the tap points
|
||||||
|
if(Math.abs(this._lastX - this._startX) > this.dragThresholdX) {
|
||||||
|
// if the difference is greater than threshold, start dragging using the current
|
||||||
|
// point as the starting point
|
||||||
|
this._startX = this._lastX
|
||||||
|
|
||||||
|
this._isDragging = true;
|
||||||
|
// Initialize dragging
|
||||||
|
this.content.disableAnimation();
|
||||||
this._offsetX = this.getOpenAmount();
|
this._offsetX = this.getOpenAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
var newX = this._offsetX + (this._lastX - this._startX);
|
if(this._isDragging) {
|
||||||
|
this.openAmount(this._offsetX + (this._lastX - this._startX));
|
||||||
this.openAmount(newX);
|
}
|
||||||
|
|
||||||
this._lastX = e.gesture.touches[0].pageX;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user