View / remove constrainCenter method

This commit is contained in:
jahow
2019-01-12 15:49:36 +01:00
committed by Olivier Guyot
parent c2c1aa01d3
commit d991dfa54a
5 changed files with 5 additions and 19 deletions
-10
View File
@@ -665,16 +665,6 @@ class View extends BaseObject {
return size; 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. * Get the constrained resolution of this view.
* @param {number|undefined} resolution Resolution. * @param {number|undefined} resolution Resolution.
+1 -2
View File
@@ -93,7 +93,6 @@ class DragPan extends PointerInteraction {
scaleCoordinate(center, view.getResolution()); scaleCoordinate(center, view.getResolution());
rotateCoordinate(center, view.getRotation()); rotateCoordinate(center, view.getRotation());
addCoordinate(center, view.getCenter()); addCoordinate(center, view.getCenter());
center = view.constrainCenter(center);
view.setCenter(center); view.setCenter(center);
} }
} else if (this.kinetic_) { } else if (this.kinetic_) {
@@ -122,7 +121,7 @@ class DragPan extends PointerInteraction {
centerpx[1] - distance * Math.sin(angle) centerpx[1] - distance * Math.sin(angle)
]); ]);
view.animate({ view.animate({
center: view.constrainCenter(dest), center: dest,
duration: 500, duration: 500,
easing: easeOut easing: easeOut
}); });
+1 -2
View File
@@ -83,8 +83,7 @@ function onBoxEnd() {
const resolution = view.getResolutionForExtent(extent, size); const resolution = view.getResolutionForExtent(extent, size);
const zoom = view.getValidZoomLevel(view.getZoomForResolution(resolution)); const zoom = view.getValidZoomLevel(view.getZoomForResolution(resolution));
let center = getCenter(extent); const center = getCenter(extent);
center = view.constrainCenter(center);
view.animate({ view.animate({
zoom: zoom, zoom: zoom,
+2 -4
View File
@@ -111,8 +111,7 @@ class Interaction extends BaseObject {
export function pan(view, delta, opt_duration) { export function pan(view, delta, opt_duration) {
const currentCenter = view.getCenter(); const currentCenter = view.getCenter();
if (currentCenter) { if (currentCenter) {
const center = view.constrainCenter( const center = [currentCenter[0] + delta[0], currentCenter[1] + delta[1]];
[currentCenter[0] + delta[0], currentCenter[1] + delta[1]]);
if (opt_duration) { if (opt_duration) {
view.animate({ view.animate({
duration: opt_duration, 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 // the constraint to it, and then calculate back the anchor
if (opt_anchor) { if (opt_anchor) {
const currentCenter = view.getCenter(); const currentCenter = view.getCenter();
let center = view.calculateCenterZoom(newResolution, opt_anchor); const center = view.calculateCenterZoom(newResolution, opt_anchor);
center = view.constrainCenter(center);
opt_anchor = [ opt_anchor = [
(newResolution * currentCenter[0] - currentResolution * center[0]) / (newResolution * currentCenter[0] - currentResolution * center[0]) /
+1 -1
View File
@@ -234,7 +234,7 @@ class MouseWheelZoom extends Interaction {
} }
if (this.lastAnchor_) { if (this.lastAnchor_) {
const center = view.calculateCenterZoom(resolution, this.lastAnchor_); const center = view.calculateCenterZoom(resolution, this.lastAnchor_);
view.setCenter(view.constrainCenter(center)); view.setCenter(center);
} }
view.setResolution(resolution); view.setResolution(resolution);