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

Add a function to remove a registered gesture recognizer in gestures #12271

Merged

Conversation

cathyxz
Copy link
Contributor

@cathyxz cathyxz commented Dec 1, 2017

Closes #12112.

This is a small PR. Please review the API for this new function and give feedback on whether it seems reasonable. The reason I'm proposing this function is because using SwipeXY to pan on image-viewer conflicts with using SwipeY to swipe-to-close on amp-lightbox-viewer. We want to deregister the SwipeXY on image-viewer when the image isn't scaled.

This PR enables swipe up to close lightbox, prototype on feature branch, deployment in progress on heroku for iOS testing. The actual lightbox swipe to close feature will be in a separate PR that is based off of #12256.

@cathyxz
Copy link
Contributor Author

cathyxz commented Dec 2, 2017

Merging master onto this branch for test fix in #12272.

@cathyxz
Copy link
Contributor Author

cathyxz commented Dec 2, 2017

/to @cvializ @aghassemi
/fyi @dvoytenko

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.

LGTM

*/
removeGesture(recognizerConstr) {
const type = new recognizerConstr(this).getType();
const overserver = this.overservers_[type];
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be nice if we could get the type of the constructor without creating an instance, but it doesn't look like there's another way to do it right now without refactoring, maybe adding an inherited static method on the subclasses to replace the hardcoded string in the constructor. Not necessary to fix, just thinking out loud.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can investigate feasibility and add a GFI task to refactor.

* @param {function(new:GestureRecognizer<DATA>, !Gestures)} recognizerConstr
* @return {boolean}
*/
removeGesture(recognizerConstr) {
Copy link
Contributor

@aghassemi aghassemi Dec 4, 2017

Choose a reason for hiding this comment

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

Could this become a remove (or unlisten) on GestureRecognizer class and hence on every recognizer instance?

My concern with current approach is that it gives one part of the code ability to unregister handlers for everyone which breaks code isolation.

Is there a use-case that unregistering handlers individually is not enough?

Copy link
Contributor

Choose a reason for hiding this comment

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

chatted offline, gesture instance is tied to the element so this is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anymore changes to address or are we good for merge? =)

Copy link
Contributor

Choose a reason for hiding this comment

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

good to go, merged,

@aghassemi aghassemi merged commit 9a7c6eb into ampproject:master Dec 4, 2017
@cathyxz cathyxz deleted the feature/gesture-recognizer-remove branch December 4, 2017 20:49
ghost pushed a commit that referenced this pull request Dec 6, 2017
gzgogo pushed a commit to gzgogo/amphtml that referenced this pull request Jan 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lightbox 2.0: Create removeGestureRecognizer function in gestures.js class
5 participants