View / remove constrainCenter method
This commit is contained in:
@@ -665,16 +665,6 @@ class View extends BaseObject {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the constrained center of this view.
|
||||
* @param {import("./coordinate.js").Coordinate|undefined} center Center.
|
||||
* @return {import("./coordinate.js").Coordinate|undefined} Constrained center.
|
||||
* @api
|
||||
*/
|
||||
constrainCenter(center) {
|
||||
return this.constraints_.center(center);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the constrained resolution of this view.
|
||||
* @param {number|undefined} resolution Resolution.
|
||||
|
||||
@@ -93,7 +93,6 @@ class DragPan extends PointerInteraction {
|
||||
scaleCoordinate(center, view.getResolution());
|
||||
rotateCoordinate(center, view.getRotation());
|
||||
addCoordinate(center, view.getCenter());
|
||||
center = view.constrainCenter(center);
|
||||
view.setCenter(center);
|
||||
}
|
||||
} else if (this.kinetic_) {
|
||||
@@ -122,7 +121,7 @@ class DragPan extends PointerInteraction {
|
||||
centerpx[1] - distance * Math.sin(angle)
|
||||
]);
|
||||
view.animate({
|
||||
center: view.constrainCenter(dest),
|
||||
center: dest,
|
||||
duration: 500,
|
||||
easing: easeOut
|
||||
});
|
||||
|
||||
@@ -83,8 +83,7 @@ function onBoxEnd() {
|
||||
const resolution = view.getResolutionForExtent(extent, size);
|
||||
const zoom = view.getValidZoomLevel(view.getZoomForResolution(resolution));
|
||||
|
||||
let center = getCenter(extent);
|
||||
center = view.constrainCenter(center);
|
||||
const center = getCenter(extent);
|
||||
|
||||
view.animate({
|
||||
zoom: zoom,
|
||||
|
||||
@@ -111,8 +111,7 @@ class Interaction extends BaseObject {
|
||||
export function pan(view, delta, opt_duration) {
|
||||
const currentCenter = view.getCenter();
|
||||
if (currentCenter) {
|
||||
const center = view.constrainCenter(
|
||||
[currentCenter[0] + delta[0], currentCenter[1] + delta[1]]);
|
||||
const center = [currentCenter[0] + delta[0], currentCenter[1] + delta[1]];
|
||||
if (opt_duration) {
|
||||
view.animate({
|
||||
duration: opt_duration,
|
||||
@@ -209,8 +208,7 @@ export function zoomByDelta(view, delta, opt_anchor, opt_duration) {
|
||||
// the constraint to it, and then calculate back the anchor
|
||||
if (opt_anchor) {
|
||||
const currentCenter = view.getCenter();
|
||||
let center = view.calculateCenterZoom(newResolution, opt_anchor);
|
||||
center = view.constrainCenter(center);
|
||||
const center = view.calculateCenterZoom(newResolution, opt_anchor);
|
||||
|
||||
opt_anchor = [
|
||||
(newResolution * currentCenter[0] - currentResolution * center[0]) /
|
||||
|
||||
@@ -234,7 +234,7 @@ class MouseWheelZoom extends Interaction {
|
||||
}
|
||||
if (this.lastAnchor_) {
|
||||
const center = view.calculateCenterZoom(resolution, this.lastAnchor_);
|
||||
view.setCenter(view.constrainCenter(center));
|
||||
view.setCenter(center);
|
||||
}
|
||||
view.setResolution(resolution);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user