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

ScrollZoomHandler does not always apply options properly #5501

Closed
bartcorremans opened this issue Oct 23, 2017 · 3 comments
Closed

ScrollZoomHandler does not always apply options properly #5501

bartcorremans opened this issue Oct 23, 2017 · 3 comments

Comments

@bartcorremans
Copy link

mapbox-gl-js version: v0.41.0

Steps to Trigger Behavior

  1. Call map.scrollZoom.disable() (or set scrollZoom to false in options when creating map)
  2. Call map.scrollZoom.enable()
  3. Call map.scrollZoom.enable({ around: 'center' })

Expected Behavior

Calling enable() the second time should apply the options object and make the scroll zoom handler scroll around the centre of the map instead of the cursor.

Actual Behavior

The scroll zoom handler does not apply the options on the second call.

The opposite is true also; calling enable() with options and then calling enable() again without options will not properly reset the options.

https://jsbin.com/tupovojawu/1/edit?html,js,output

@mollymerp
Copy link
Contributor

@bartcorremans thanks for using mapbox and for the detailed report!
As the function is written, if you call map.scrollZoom.enable() when the control is already enabled, it returns without doing anything, and this is consistent with the rest of our mouse/keyboard handlers. Your example works if you add a call to map.scrollZoom.disable() in the first timeout.

It might make sense to add a method that allows users to set the around option separately from enabling/disabling the handler.

https://jsbin.com/tupovojawu/1/edit?html,js,output

enable(options: any) {
if (this.isEnabled()) return;

@mollymerp
Copy link
Contributor

adding a setter for around falls under #4029

@bartcorremans
Copy link
Author

Thanks for the reply!

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

No branches or pull requests

2 participants