You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/06/10 03:32:52 UTC
[incubator-echarts] branch label-enhancement updated: ts: update
roamHelper
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch label-enhancement
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
The following commit(s) were added to refs/heads/label-enhancement by this push:
new 1dc916d ts: update roamHelper
1dc916d is described below
commit 1dc916d0fea606f3b6b2029f94e24366c2e52dc7
Author: pissang <bm...@gmail.com>
AuthorDate: Wed Jun 10 11:32:14 2020 +0800
ts: update roamHelper
---
src/component/helper/roamHelper.ts | 35 +++++++++++++++--------------------
1 file changed, 15 insertions(+), 20 deletions(-)
diff --git a/src/component/helper/roamHelper.ts b/src/component/helper/roamHelper.ts
index df06db0..810138f 100644
--- a/src/component/helper/roamHelper.ts
+++ b/src/component/helper/roamHelper.ts
@@ -17,35 +17,30 @@
* under the License.
*/
-// @ts-nocheck
+import Element from 'zrender/src/Element';
+
+interface ControllerHost {
+ target: Element,
+ zoom: number
+ zoomLimit: {min: number, max: number}
+}
/**
* For geo and graph.
- *
- * @param {Object} controllerHost
- * @param {module:zrender/Element} controllerHost.target
*/
-export function updateViewOnPan(controllerHost, dx, dy) {
+export function updateViewOnPan(controllerHost: ControllerHost, dx: number, dy: number) {
const target = controllerHost.target;
- const pos = target.position;
- pos[0] += dx;
- pos[1] += dy;
+ target.x += dx;
+ target.y += dy;
target.dirty();
}
/**
* For geo and graph.
- *
- * @param {Object} controllerHost
- * @param {module:zrender/Element} controllerHost.target
- * @param {number} controllerHost.zoom
- * @param {number} controllerHost.zoomLimit like: {min: 1, max: 2}
*/
-export function updateViewOnZoom(controllerHost, zoomDelta, zoomX, zoomY) {
+export function updateViewOnZoom(controllerHost: ControllerHost, zoomDelta: number, zoomX: number, zoomY: number) {
const target = controllerHost.target;
const zoomLimit = controllerHost.zoomLimit;
- const pos = target.position;
- const scale = target.scale;
let newZoom = controllerHost.zoom = controllerHost.zoom || 1;
newZoom *= zoomDelta;
@@ -60,10 +55,10 @@ export function updateViewOnZoom(controllerHost, zoomDelta, zoomX, zoomY) {
const zoomScale = newZoom / controllerHost.zoom;
controllerHost.zoom = newZoom;
// Keep the mouse center when scaling
- pos[0] -= (zoomX - pos[0]) * (zoomScale - 1);
- pos[1] -= (zoomY - pos[1]) * (zoomScale - 1);
- scale[0] *= zoomScale;
- scale[1] *= zoomScale;
+ target.x -= (zoomX - target.x) * (zoomScale - 1);
+ target.y -= (zoomY - target.y) * (zoomScale - 1);
+ target.scaleX *= zoomScale;
+ target.scaleY *= zoomScale;
target.dirty();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org