Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lightbox bug where panning results in carousel swipe #13125

Merged
merged 2 commits into from Jan 30, 2018

Conversation

cathyxz
Copy link
Contributor

@cathyxz cathyxz commented Jan 29, 2018

Fixes: double tap to zoom has a weird animation where you can’t move the image around after you have zoomed in.

@@ -465,6 +465,7 @@ export class AmpImageViewer extends AMP.BaseElement {
// Movable.
this.unlistenOnSwipePan_ = this.gestures_
.onGesture(SwipeXYRecognizer, e => {
event.preventDefault();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like all the gesture handles preventDefault now. Maybe Gestures.get( doesn't need to the /* opt_shouldNotPreventDefault */true anymore? then we can remove all the event.preventDefault();.

Only one to double check is onPointerDown which preventsDefaults conditionally. Not sure what happens if it does it in all cases.

Approving the PR and leavings this to your discretion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why it has to be like this is because we only want to preventDefault AFTER the gesture triggers, but not when an event triggers a pending gesture. /* opt_shouldNotPreventDefault */false results in preventing default being called on single taps, which is why it broke lightbox toggle.

This should have happened in #12930.

Copy link
Contributor

@cvializ cvializ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand wanting to get the fix in, but I would feel better about approving this if there was a TODO issue comment added to switch from using the window.event global to using the actual event object passed to the appropriate event listener.

@cathyxz
Copy link
Contributor Author

cathyxz commented Jan 30, 2018

So it's not possible to get an actual event, because gesture recognizers are triggered on a very specific series of touch start, touch move, and touch end events. It would be misleading to trigger on any of them, and implementation-wise messy to trigger on a click. I'm going to add a comment about revisiting this after resolving #12881.

@cathyxz cathyxz merged commit 521b328 into ampproject:master Jan 30, 2018
@cathyxz cathyxz deleted the bugfix/pan-swipe-bug branch January 30, 2018 02:50
RanAbram pushed a commit to RanAbram/amphtml that referenced this pull request Mar 12, 2018
…13125)

* Fix lightbox bug where panning results in carousel swipe

* Add comment regarding event.preventDefault usage with gesture recognizers
protonate pushed a commit to protonate/amphtml that referenced this pull request Mar 15, 2018
…13125)

* Fix lightbox bug where panning results in carousel swipe

* Add comment regarding event.preventDefault usage with gesture recognizers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants