View / add a method to compute a valid zoom level
The `getValidZoomLevel` apply the current resolution constraint to return a value that is guaranteed valid. This is used for interactions & controls which need a target value to work: the +/- buttons, the zoom clider, the dragbox zoom and the mouse wheel zoom.
This commit is contained in:
@@ -239,8 +239,10 @@ class MouseWheelZoom extends Interaction {
|
||||
view.setResolution(resolution);
|
||||
|
||||
if (rebound === 0 && this.constrainResolution_) {
|
||||
const zoomDelta = delta > 0 ? -1 : 1;
|
||||
const newZoom = view.getValidZoomLevel(view.getZoom() + zoomDelta);
|
||||
view.animate({
|
||||
resolution: view.constrainResolution(resolution, delta > 0 ? -1 : 1),
|
||||
resolution: view.getResolutionForZoom(newZoom),
|
||||
easing: easeOut,
|
||||
anchor: this.lastAnchor_,
|
||||
duration: this.duration_
|
||||
|
||||
Reference in New Issue
Block a user