Skip to content

Commit c413cc5

Browse files
committed
resize bug fixed
1 parent e7dc049 commit c413cc5

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

src/component/base.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ define(function(require) {
154154
+ finalTextStyle.fontSize + 'px '
155155
+ finalTextStyle.fontFamily;
156156
}
157+
158+
function resize() {
159+
self.refresh && self.refresh();
160+
}
157161

158162
/**
159163
* 清除图形数据,实例仍可用
@@ -182,6 +186,7 @@ define(function(require) {
182186
self.getFont = getFont;
183187
self.clear = clear;
184188
self.dispose = dispose;
189+
self.resize = resize;
185190
}
186191

187192
return Base;

src/component/dataZoom.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,8 +975,39 @@ define(function (require) {
975975
_buildShape();
976976
}
977977
}
978+
979+
/**
980+
* 避免dataZoom带来两次refresh,不设refresh接口,resize重复一下buildshape逻辑
981+
*/
982+
function resize() {
983+
self.clear();
984+
985+
// 自己show 或者 toolbox启用且dataZoom有效
986+
if (option.dataZoom.show
987+
|| (
988+
self.deepQuery([option], 'toolbox.show')
989+
&& self.deepQuery([option], 'toolbox.feature.dataZoom')
990+
)
991+
) {
992+
_location = _getLocation();
993+
_zoom = _getZoom();
994+
}
995+
996+
if (option.dataZoom.show) {
997+
_buildBackground();
998+
_buildDataBackground();
999+
_buildFiller();
1000+
_bulidHandle();
1001+
1002+
for (var i = 0, l = self.shapeList.length; i < l; i++) {
1003+
self.shapeList[i].id = zr.newShapeId(self.type);
1004+
zr.addShape(self.shapeList[i]);
1005+
}
1006+
}
1007+
}
9781008

9791009
self.init = init;
1010+
self.resize = resize;
9801011
self.syncBackupData = syncBackupData;
9811012
self.absoluteZoom = absoluteZoom;
9821013
self.rectZoom = rectZoom;

src/component/grid.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ define(function (require) {
3131
var _y;
3232
var _width;
3333
var _height;
34+
var _zrWidth;
35+
var _zrHeight;
3436

3537
/**
3638
* 构造函数默认执行的初始化方法,也用于创建实例后动态修改
@@ -47,16 +49,18 @@ define(function (require) {
4749
_y = gridOption.y;
4850
var x2 = gridOption.x2;
4951
var y2 = gridOption.y2;
52+
_zrWidth = zr.getWidth();
53+
_zrHeight = zr.getHeight();
5054

5155
if (typeof gridOption.width == 'undefined') {
52-
_width = zr.getWidth() - _x - x2;
56+
_width = _zrWidth - _x - x2;
5357
}
5458
else {
5559
_width = gridOption.width;
5660
}
5761

5862
if (typeof gridOption.height == 'undefined') {
59-
_height = zr.getHeight() - _y - y2;
63+
_height = _zrHeight - _y - y2;
6064
}
6165
else {
6266
_height = gridOption.height;
@@ -114,6 +118,16 @@ define(function (require) {
114118
height : _height
115119
};
116120
}
121+
122+
function refresh(newOption) {
123+
if (_zrWidth != zr.getWidth()
124+
|| _zrHeight != zr.getHeight()
125+
|| newOption
126+
) {
127+
self.clear();
128+
init(newOption || option);
129+
}
130+
}
117131

118132
self.init = init;
119133
self.getX = getX;
@@ -123,6 +137,7 @@ define(function (require) {
123137
self.getXend = getXend;
124138
self.getYend = getYend;
125139
self.getArea = getArea;
140+
self.refresh = refresh;
126141

127142
init(option);
128143
}

0 commit comments

Comments
 (0)