diff --git a/dist/ionic.js b/dist/ionic.js index 4deb5a2fef..5cdd6b11cd 100644 --- a/dist/ionic.js +++ b/dist/ionic.js @@ -2444,6 +2444,7 @@ ionic.controllers.NavController.prototype = { this.left = options.left; this.right = options.right; this.content = options.content; + this.dragThresholdX = options.dragThresholdX || 10; this._rightShowing = false; this._leftShowing = false; @@ -2661,33 +2662,37 @@ ionic.controllers.NavController.prototype = { // End a drag with the given event _endDrag: function(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 _handleDrag: function(e) { - if(!this._isDragging) { - this._initDrag(e); - + // If we don't have start coords, grab and store them + if(!this._startX) { this._startX = e.gesture.touches[0].pageX; 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(); } - var newX = this._offsetX + (this._lastX - this._startX); - - this.openAmount(newX); - - this._lastX = e.gesture.touches[0].pageX; + if(this._isDragging) { + this.openAmount(this._offsetX + (this._lastX - this._startX)); + } } }; diff --git a/js/controllers/sideMenuController.js b/js/controllers/sideMenuController.js index 3aac9e913e..72e1cffa22 100644 --- a/js/controllers/sideMenuController.js +++ b/js/controllers/sideMenuController.js @@ -12,6 +12,7 @@ this.left = options.left; this.right = options.right; this.content = options.content; + this.dragThresholdX = options.dragThresholdX || 10; this._rightShowing = false; this._leftShowing = false; @@ -229,33 +230,37 @@ // End a drag with the given event _endDrag: function(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 _handleDrag: function(e) { - if(!this._isDragging) { - this._initDrag(e); - + // If we don't have start coords, grab and store them + if(!this._startX) { this._startX = e.gesture.touches[0].pageX; 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(); } - var newX = this._offsetX + (this._lastX - this._startX); - - this.openAmount(newX); - - this._lastX = e.gesture.touches[0].pageX; + if(this._isDragging) { + this.openAmount(this._offsetX + (this._lastX - this._startX)); + } } };