Skip to content

Commit

Permalink
Fix lightbox bug where panning results in carousel swipe (ampproject#…
Browse files Browse the repository at this point in the history
…13125)

* Fix lightbox bug where panning results in carousel swipe

* Add comment regarding event.preventDefault usage with gesture recognizers
  • Loading branch information
cathyxz authored and RanAbram committed Mar 12, 2018
1 parent d4666af commit a37e812
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions extensions/amp-image-viewer/0.1/amp-image-viewer.js
Expand Up @@ -409,6 +409,10 @@ export class AmpImageViewer extends AMP.BaseElement {

/** @private */
setupGestures_() {
// TODO (#12881): this and the subsequent use of event.preventDefault
// is a temporary solution to #12362. We should revisit this problem after
// resolving #12881 or change the use of window.event to the specific event
// triggering the gesture.
this.gestures_ = Gestures.get(
this.element,
/* opt_shouldNotPreventDefault */true
Expand Down Expand Up @@ -465,6 +469,7 @@ export class AmpImageViewer extends AMP.BaseElement {
// Movable.
this.unlistenOnSwipePan_ = this.gestures_
.onGesture(SwipeXYRecognizer, e => {
event.preventDefault();
this.onMove_(e.data.deltaX, e.data.deltaY, false);
if (e.data.last) {
this.onMoveRelease_(e.data.velocityX, e.data.velocityY);
Expand Down

0 comments on commit a37e812

Please sign in to comment.