提交 fa89024a 编写于 作者: L lang

scaleLimit is a {min, max} object

上级 8ef4fac0
...@@ -6,7 +6,7 @@ define(function (require) { ...@@ -6,7 +6,7 @@ define(function (require) {
* Calculate pan and zoom which from roamDetail model * Calculate pan and zoom which from roamDetail model
* @param {module:echarts/model/Model} roamDetailModel * @param {module:echarts/model/Model} roamDetailModel
* @param {Object} payload * @param {Object} payload
* @param {Array.<number>} [zoomLimit] * @param {Object} [zoomLimit]
*/ */
roamHelper.calcPanAndZoom = function ( roamHelper.calcPanAndZoom = function (
roamDetailModel, payload, zoomLimit roamDetailModel, payload, zoomLimit
...@@ -27,8 +27,8 @@ define(function (require) { ...@@ -27,8 +27,8 @@ define(function (require) {
if (zoom != null) { if (zoom != null) {
if (zoomLimit) { if (zoomLimit) {
zoom = Math.max( zoom = Math.max(
Math.min(previousZoom * zoom, zoomLimit[1]), Math.min(previousZoom * zoom, zoomLimit.max),
zoomLimit[0] zoomLimit.min
) / previousZoom; ) / previousZoom;
} }
var fixX = (payload.originX - panX) * (zoom - 1); var fixX = (payload.originX - panX) * (zoom - 1);
......
...@@ -99,8 +99,8 @@ define(function (require) { ...@@ -99,8 +99,8 @@ define(function (require) {
newZoom *= zoomDelta; newZoom *= zoomDelta;
if (zoomLimit) { if (zoomLimit) {
newZoom = Math.max( newZoom = Math.max(
Math.min(zoomLimit[1], newZoom), Math.min(zoomLimit.max, newZoom),
zoomLimit[0] zoomLimit.min
); );
} }
var zoomScale = newZoom / this.zoom; var zoomScale = newZoom / this.zoom;
...@@ -140,9 +140,10 @@ define(function (require) { ...@@ -140,9 +140,10 @@ define(function (require) {
this.rect = rect; this.rect = rect;
/** /**
* @type {Array.<number>} * { min: 1, max: 2 }
* @type {Object}
*/ */
this.zoomLimit = null; this.zoomLimit;
/** /**
* @type {number} * @type {number}
......
...@@ -121,7 +121,7 @@ define(function (require) { ...@@ -121,7 +121,7 @@ define(function (require) {
var zoomLimit = this.zoomLimit; var zoomLimit = this.zoomLimit;
if (zoomLimit) { if (zoomLimit) {
zoom = Math.max( zoom = Math.max(
Math.min(zoom, zoomLimit[1]), zoomLimit[0] Math.min(zoom, zoomLimit.max), zoomLimit.min
); );
} }
......
...@@ -259,7 +259,10 @@ ...@@ -259,7 +259,10 @@
geo: { geo: {
map: 'china', map: 'china',
roam: true, roam: true,
scaleLimit: [1, 2], scaleLimit: {
min: 1,
max: 2
},
roamDetail: { roamDetail: {
x: -200, x: -200,
y: -200, y: -200,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册