提交 a970c749 编写于 作者: P pah100

fix the previous commit.

上级 03f3effb
define(function (require) {
var helper = {};
/**
* For geo and graph.
*
* @param {Object} controllerHost
* @param {module:zrender/Element} controllerHost.target
*/
helper.updateViewOnPan = function (controllerHost, dx, dy) {
var target = controllerHost.target;
var pos = target.position;
pos[0] += dx;
pos[1] += 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}
*/
helper.updateViewOnZoom = function (controllerHost, zoomDelta, zoomX, zoomY) {
var target = controllerHost.target;
var zoomLimit = controllerHost.zoomLimit;
var pos = target.position;
var scale = target.scale;
var newZoom = controllerHost.zoom = controllerHost.zoom || 1;
newZoom *= zoomDelta;
if (zoomLimit) {
var zoomMin = zoomLimit.min || 0;
var zoomMax = zoomLimit.max || Infinity;
newZoom = Math.max(
Math.min(zoomMax, newZoom),
zoomMin
);
}
var 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.dirty();
};
/**
* Avoid that: mouse click on a elements that is over geo or graph,
* but roam is triggered.
*/
helper.onIrrelevantElement = function (x, y, ecModel, api, targetModel) {
var model = api.getComponentByElement(api.getZr().handler.findHover(x, y, null, true));
var coordSys = model && model.coordinateSystem;
return model
&& model !== targetModel
&& (model.mainType !== 'series' || !coordSys || coordSys.model !== targetModel);
};
return helper;
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册