View / add a 'smoothResolutionConstraint' options

When enabled (true by default), the resolution min/max values will be applied with
a smoothing effect for a better user experience.
This commit is contained in:
Olivier Guyot
2019-01-20 20:45:49 +01:00
parent e023c144bb
commit ef6d17d817
6 changed files with 187 additions and 65 deletions
+3 -3
View File
@@ -33,9 +33,9 @@ export function createExtent(extent, onlyCenter, smooth) {
const maxX = extent[2] - viewWidth / 2;
const minY = extent[1] + viewHeight / 2;
const maxY = extent[3] - viewHeight / 2;
let x = clamp(center[0], minX, maxX);
let y = clamp(center[1], minY, maxY);
let ratio = 30 * resolution;
let x = minX > maxX ? (maxX + minX) / 2 : clamp(center[0], minX, maxX);
let y = minY > maxY ? (maxY + minY) / 2 : clamp(center[1], minY, maxY);
const ratio = 30 * resolution;
// during an interaction, allow some overscroll
if (opt_isMoving && smooth) {