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

Only update the scale value at the end of the zoom animation #2952

Merged
merged 1 commit into from
Oct 13, 2017

Conversation

fredj
Copy link
Member

@fredj fredj commented Oct 3, 2017

Otherwise $applyAsync is called on every frame change (~60 / second)

Otherwise `$applyAsync` is called on every frame change (~60 / second)
@adube
Copy link
Contributor

adube commented Oct 3, 2017

@fredj I'm interested in this. Here's why.

Since OpenLayers 3.20.0 (if I recall correctly) the change:resolution event (on the resolution property of the ol.View) is fired on every frame change. Before that, it used to be fired once, and it had the value of the 'end' resolution right away.

That change caused this kind of problem that you raised and addressed with this fix. Oh, btw I agree with your fix.

The thing is: natively, within OpenLayers, it would be nice to be able to listen to an event that would only be fired when the resolution changes to one of the resolution we have in the constraint. Hear me out. I would suggest the following enhancement within OL.

Introduce a new ol.ViewProperty.CONSTRAINT_RESOLUTION that would only be set when the value is one among the resolution that the user specified as constraint when the view was created. When setting the resolution, the view would be responsible of checking if it's one of the constraint resolution and set it as well if it does. With this, one could register an event on that property, which would avoid the management that needs to be repeated otherwise.

I would also add: it would make sense to set the property to null (only once) if the current property has a value, but we're currently with a resolution between those defined as constrains. This would allow a listener to act on null value as well. For example:

  • while zooming (not in constraint, value is null) - hide something
  • at the end (constrain value is set) - show something

What do you think?

@fredj
Copy link
Member Author

fredj commented Oct 13, 2017

Yes; it definitely can be improved in openlayers; maybe using a combination of change:resolution and moveend

@fredj fredj merged commit 68b9a86 into master Oct 13, 2017
@fredj fredj deleted the scaleselector_better_refresh branch October 13, 2017 06:47
@sbrunner sbrunner added this to the 2.3 milestone Apr 12, 2018
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.

3 participants