Skip to content

Commit

Permalink
prevent touchmove while swiping
Browse files Browse the repository at this point in the history
  • Loading branch information
MeTaNoV committed Apr 2, 2016
1 parent f7f30c9 commit 6d87124
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions iron-swipeable-pages.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
},

/**
* The maximum global CSS transition duration applied if swiping involves more than one
* The maximum global CSS transition duration applied if swiping involves more than one
* page transition using selection instead of manual swiping.
*/
maximumTransitionDuration: {
Expand Down Expand Up @@ -185,21 +185,19 @@
return;
// TODO PG: check for webkit 'webkitTransitionEnd'
this.listen(page, 'transitionend', '_onTransitionEnd');
console.log("adding page!");
},

_removePage: function(page) {
if (page.nodeType !== Node.ELEMENT_NODE)
return;
// TODO PG: check for webkit 'webkitTransitionEnd'
this.unlisten(page, 'transitionend', '_onTransitionEnd');
console.log("removing page!");
},

_onDomChange: function(event) {
// something might have change inside a template helper, e.g. `dom-if`
// so we should call forceSynchronousItemUpdate() to update the item list
// since it is not performance optimal, this is an opt-in option and we raise a
// since it is not performance optimal, this is an opt-in option and we raise a
// warning if this occurs and the option is not enabled
if (this.forceUpdate) {
this.forceSynchronousItemUpdate();
Expand Down Expand Up @@ -242,6 +240,8 @@
this._setUpSwipePages();
this._animatePages(trackData.dx);
this._switchPageIfNecessary(trackData.dx);
// Prevent regular touchmove event (disables vertical scroll)
window.addEventListener('touchmove', this._preventTouchMove);
},

_trackMove: function(trackData) {
Expand Down Expand Up @@ -271,6 +271,12 @@
} else {
this._animatePages(0);
}
// Enable regular touchmove event (enables vertical scroll again)
window.removeEventListener('touchmove', this._preventTouchMove);
},

_preventTouchMove: function (e) {
return e && e.preventDefault();
},

_onIronDeselectItem: function(event) {
Expand Down Expand Up @@ -360,7 +366,7 @@
}
},

// this function is useful if only 2 pages are available and we need to switch the next/previous page
// this function is useful if only 2 pages are available and we need to switch the next/previous page
// on the left/right side depending on the direction of the swipe given with `dx`
_switchPageIfNecessary: function(dx) {
if (this._leftCandidate && this._rightCandidate && this._leftCandidate === this._rightCandidate) {
Expand Down

0 comments on commit 6d87124

Please sign in to comment.