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

Navigation recenter, pinch and bubbles options #1628

Merged
merged 31 commits into from
Mar 22, 2019

Conversation

EnyaoGu
Copy link
Contributor

@EnyaoGu EnyaoGu commented Mar 19, 2019

This PR is a combination of #1621, #1622, and #1625.

That PRs have some conflict with each other. I fix the conflicts to make it easier to pull. @atmgrifter00

This was referenced Mar 19, 2019
Copy link
Contributor

@atmgrifter00 atmgrifter00 left a comment

Choose a reason for hiding this comment

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

I feel like we're missing a good set of tests for your changes. I would expect to see some tests that demonstrate we can disable recentering, and tests that show we properly allow/disallow event propagation.

source/jquery.flot.touch.js Outdated Show resolved Hide resolved
e.preventDefault();
e.stopPropagation();
if (!plot.getOptions().propagateOriginTouch) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this condition can become:

if ((e.touches.length === 1 && options.pan.enableTouch)
|| (e.touches.length === 2 && options.zoom.enableTouch))

This should equate to if a user has pan enabled and does a pan gesture we will stop the propagation of the event, and will similarly do so when a user has zoom enabled and performs a pinch gesture.

The extra propagateOriginTouch option can present a confusing state where a user can still propagate the event despite it being handled. I don't see a good reason to allow this.

Copy link
Contributor Author

@EnyaoGu EnyaoGu Mar 20, 2019

Choose a reason for hiding this comment

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

I am afraid that this way would not meet our expectation. We'd like to enable pan, but disable zoom(pinch). In this case, the first touchstart event and the last touchend of a pinch interaction will be stopped from propagation, because these events have only one touch (the second touch does not start or already ends). However, the gesture recognizer hammerjs we used outside need all of those events to recognize the actual gesture. I have tried and found out the outside hammer fails.

By the way, completely or partially stopping propagation of the origin events by a gesture recognizer seems not very common (while preventing default is common). I tested hammerjs that it does not stop any origin events even the events are handled as a gesture. So I would say propagate handled events is not a confusing behavior, actually, it is the expected behavior for most cases.

Again, my suggestion is, at least, to have an option to completely disable the stopping-event-propagation behavior. I even agree to completely remove it.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine. Can we rename the option to propagateSupportedGestures?

Copy link
Contributor Author

@EnyaoGu EnyaoGu Mar 20, 2019

Choose a reason for hiding this comment

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

I feel it a little misleading to name this option with gesture. It controls the behavior of the origin touch events like touchstart and touchmove, while I will understand gesture as pinchmove or doubletap. propagateSupportedGesture sounds like it will allow the gesture event (e.g. pinchmove) to bubble.

Anyway, I can rename it as your comments if you insist.

source/jquery.flot.touchNavigate.js Show resolved Hide resolved
source/jquery.flot.touch.js Outdated Show resolved Hide resolved
source/jquery.flot.navigate.js Outdated Show resolved Hide resolved
source/jquery.flot.navigate.js Outdated Show resolved Hide resolved
docs/navigate.md Outdated Show resolved Hide resolved
docs/navigate.md Outdated Show resolved Hide resolved
@@ -32,7 +32,7 @@ The plugin supports these options:
enableTouch: true
}

propagateOriginTouch: false,
propagateSupportedGesture: false,
Copy link
Contributor Author

@EnyaoGu EnyaoGu Mar 21, 2019

Choose a reason for hiding this comment

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

I renamed it now since I have not got your agreement to keep it propagateOriginTouch. I hope we can have the version bump ASAP then I will make changes into webcharts.

@atmgrifter00 atmgrifter00 merged commit 86bc4eb into flot:master Mar 22, 2019
@EnyaoGu EnyaoGu deleted the improveNavigation branch March 25, 2019 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants