Separate internal and API methods for the view

This commit is contained in:
Tim Schaub
2019-08-11 17:28:28 -06:00
parent f73d0b16ec
commit c03c359a20
17 changed files with 214 additions and 69 deletions
+3 -3
View File
@@ -92,7 +92,7 @@ class DragPan extends PointerInteraction {
const view = map.getView();
scaleCoordinate(delta, view.getResolution());
rotateCoordinate(delta, view.getRotation());
view.adjustCenter(delta);
view.adjustCenterInternal(delta);
}
} else if (this.kinetic_) {
// reset so we don't overestimate the kinetic energy after
@@ -113,13 +113,13 @@ class DragPan extends PointerInteraction {
if (!this.noKinetic_ && this.kinetic_ && this.kinetic_.end()) {
const distance = this.kinetic_.getDistance();
const angle = this.kinetic_.getAngle();
const center = /** @type {!import("../coordinate.js").Coordinate} */ (view.getCenter());
const center = view.getCenterInternal();
const centerpx = map.getPixelFromCoordinate(center);
const dest = map.getCoordinateFromPixel([
centerpx[0] - distance * Math.cos(angle),
centerpx[1] - distance * Math.sin(angle)
]);
view.animate({
view.animateInternal({
center: view.getConstrainedCenter(dest),
duration: 500,
easing: easeOut
+1 -1
View File
@@ -78,7 +78,7 @@ class DragRotate extends PointerInteraction {
Math.atan2(size[1] / 2 - offset[1], offset[0] - size[0] / 2);
if (this.lastAngle_ !== undefined) {
const delta = theta - this.lastAngle_;
view.adjustRotation(-delta);
view.adjustRotationInternal(-delta);
}
this.lastAngle_ = theta;
}
+1 -1
View File
@@ -87,7 +87,7 @@ class DragRotateAndZoom extends PointerInteraction {
const view = map.getView();
if (this.lastAngle_ !== undefined) {
const angleDelta = this.lastAngle_ - theta;
view.adjustRotation(angleDelta);
view.adjustRotationInternal(angleDelta);
}
this.lastAngle_ = theta;
if (this.lastMagnitude_ !== undefined) {
+4 -4
View File
@@ -73,20 +73,20 @@ function onBoxEnd() {
let extent = this.getGeometry().getExtent();
if (this.out_) {
const mapExtent = view.calculateExtent(size);
const mapExtent = view.calculateExtentInternal(size);
const boxPixelExtent = createOrUpdateFromCoordinates([
map.getPixelFromCoordinate(getBottomLeft(extent)),
map.getPixelFromCoordinate(getTopRight(extent))]);
const factor = view.getResolutionForExtent(boxPixelExtent, size);
const factor = view.getResolutionForExtentInternal(boxPixelExtent, size);
scaleFromCenter(mapExtent, 1 / factor);
extent = mapExtent;
}
const resolution = view.getConstrainedResolution(view.getResolutionForExtent(extent, size));
const resolution = view.getConstrainedResolution(view.getResolutionForExtentInternal(extent, size));
const center = view.getConstrainedCenter(getCenter(extent), resolution);
view.animate({
view.animateInternal({
resolution: resolution,
center: center,
duration: this.duration_,
+3 -3
View File
@@ -108,10 +108,10 @@ class Interaction extends BaseObject {
* @param {number=} opt_duration Duration.
*/
export function pan(view, delta, opt_duration) {
const currentCenter = view.getCenter();
const currentCenter = view.getCenterInternal();
if (currentCenter) {
const center = [currentCenter[0] + delta[0], currentCenter[1] + delta[1]];
view.animate_({
view.animateInternal({
duration: opt_duration !== undefined ? opt_duration : 250,
easing: linear,
center: view.getConstrainedCenter(center)
@@ -138,7 +138,7 @@ export function zoomByDelta(view, delta, opt_anchor, opt_duration) {
if (view.getAnimating()) {
view.cancelAnimations();
}
view.animate({
view.animateInternal({
resolution: newResolution,
anchor: opt_anchor,
duration: opt_duration !== undefined ? opt_duration : 250,
+1 -1
View File
@@ -117,7 +117,7 @@ class PinchRotate extends PointerInteraction {
// rotate
if (this.rotating_) {
map.render();
view.adjustRotation(rotationDelta, this.anchor_);
view.adjustRotationInternal(rotationDelta, this.anchor_);
}
}