From c2a49f4e027ff324d4e0867b14dbc44773e52f04 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Thu, 19 Sep 2019 16:27:51 -0400 Subject: [PATCH] Disallow zooming past the min/max zoom bounds via scrolling or pinch-to-zoom (close #6851) --- modules/renderer/map.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/renderer/map.js b/modules/renderer/map.js index db6dd3d83..e3bd47316 100644 --- a/modules/renderer/map.js +++ b/modules/renderer/map.js @@ -426,6 +426,7 @@ export function rendererMap(context) { p0 = _getMouseCoords(source); p1 = t0.invert(p0); k2 = t0.k * Math.pow(2, -dY / 500); + k2 = clamp(k2, kMin, kMax); x2 = p0[0] - p1[0] * k2; y2 = p0[1] - p1[1] * k2; @@ -437,6 +438,7 @@ export function rendererMap(context) { p0 = _getMouseCoords(source); p1 = t0.invert(p0); k2 = t0.k * source._scale; + k2 = clamp(k2, kMin, kMax); x2 = p0[0] - p1[0] * k2; y2 = p0[1] - p1[1] * k2; @@ -452,6 +454,7 @@ export function rendererMap(context) { p0 = _getMouseCoords(source); p1 = t0.invert(p0); k2 = t0.k * Math.pow(2, -dY / 500); + k2 = clamp(k2, kMin, kMax); x2 = p0[0] - p1[0] * k2; y2 = p0[1] - p1[1] * k2; @@ -462,6 +465,7 @@ export function rendererMap(context) { p0 = _getMouseCoords(source); p1 = t0.invert(p0); k2 = t0.k * Math.pow(2, -dY / 500); + k2 = clamp(k2, kMin, kMax); x2 = p0[0] - p1[0] * k2; y2 = p0[1] - p1[1] * k2; @@ -474,6 +478,7 @@ export function rendererMap(context) { x2 = p1[0] - dX; y2 = p1[1] - dY; k2 = projection.scale(); + k2 = clamp(k2, kMin, kMax); } // something changed - replace the event transform