Add new tests for View & Interaction w/ fixes
This commit is contained in:
@@ -653,7 +653,7 @@ class View extends BaseObject {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {number|undefined} opt_rotation
|
||||
* @param {number=} opt_rotation Take into account the rotation of the viewport when giving the size
|
||||
* @return {import("./size.js").Size} Viewport size or `[100, 100]` when no viewport is found.
|
||||
*/
|
||||
getSizeFromViewport_(opt_rotation) {
|
||||
@@ -666,8 +666,10 @@ class View extends BaseObject {
|
||||
size[1] = parseInt(metrics.height, 10);
|
||||
}
|
||||
if (opt_rotation) {
|
||||
size[0] = Math.abs(size[0] * Math.cos(opt_rotation)) + Math.abs(size[1] * Math.sin(opt_rotation));
|
||||
size[1] = Math.abs(size[0] * Math.sin(opt_rotation)) + Math.abs(size[1] * Math.cos(opt_rotation));
|
||||
const w = size[0];
|
||||
const h = size[1];
|
||||
size[0] = Math.abs(w * Math.cos(opt_rotation)) + Math.abs(h * Math.sin(opt_rotation));
|
||||
size[1] = Math.abs(w * Math.sin(opt_rotation)) + Math.abs(h * Math.cos(opt_rotation));
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import BaseObject from '../Object.js';
|
||||
import {easeOut, linear} from '../easing.js';
|
||||
import InteractionProperty from './Property.js';
|
||||
import {clamp} from '../math.js';
|
||||
|
||||
|
||||
/**
|
||||
@@ -194,7 +193,6 @@ export function zoom(view, resolution, opt_anchor, opt_duration, opt_direction)
|
||||
*/
|
||||
export function zoomByDelta(view, delta, opt_anchor, opt_duration) {
|
||||
const currentZoom = view.getZoom();
|
||||
const currentResolution = view.getResolution();
|
||||
|
||||
if (currentZoom === undefined) {
|
||||
return;
|
||||
@@ -203,21 +201,6 @@ export function zoomByDelta(view, delta, opt_anchor, opt_duration) {
|
||||
const newZoom = view.getValidZoomLevel(currentZoom + delta);
|
||||
const newResolution = view.getResolutionForZoom(newZoom);
|
||||
|
||||
// If we have a constraint on center, we need to change the anchor so that the
|
||||
// new center is within the extent. We first calculate the new center, apply
|
||||
// the constraint to it, and then calculate back the anchor
|
||||
if (opt_anchor) {
|
||||
const currentCenter = view.getCenter();
|
||||
const center = view.calculateCenterZoom(newResolution, opt_anchor);
|
||||
|
||||
opt_anchor = [
|
||||
(newResolution * currentCenter[0] - currentResolution * center[0]) /
|
||||
(newResolution - currentResolution),
|
||||
(newResolution * currentCenter[1] - currentResolution * center[1]) /
|
||||
(newResolution - currentResolution)
|
||||
];
|
||||
}
|
||||
|
||||
if (opt_duration > 0) {
|
||||
if (view.getAnimating()) {
|
||||
view.cancelAnimations();
|
||||
|
||||
Reference in New Issue
Block a user