提交 7e6a433b 编写于 作者: P pah100

datazoom throttle tweak

上级 f8cd2b78
......@@ -40,8 +40,10 @@ define(function(require) {
// the filtered points when filterModel is set to 'empty', but
// be connected when set to 'filter'.
throttle: 100, // Dispatch action by the fixed rate, avoid frequency.
throttle: null, // Dispatch action by the fixed rate, avoid frequency.
// default 100. Do not throttle when use null/undefined.
// If animation === true and animationDurationUpdate > 0,
// default value is 100, otherwise 20.
start: 0, // Start percent. 0 ~ 100
end: 100, // End percent. 0 ~ 100
startValue: null, // Start value. If startValue specified, start is ignored.
......@@ -76,6 +78,11 @@ define(function(require) {
*/
this.textStyleModel;
/**
* @private
*/
this._autoThrottle = true;
var rawOption = retrieveRaw(option);
this.mergeDefaultAndTheme(option, ecModel);
......@@ -106,6 +113,8 @@ define(function(require) {
thisOption.realtime = false;
}
this._setDefaultThrottle(rawOption);
processRangeProp('start', 'startValue', rawOption, thisOption);
processRangeProp('end', 'endValue', rawOption, thisOption);
......@@ -292,6 +301,22 @@ define(function(require) {
return is;
},
/**
* @private
*/
_setDefaultThrottle: function (rawOption) {
// When first time user set throttle, auto throttle ends.
if (rawOption.hasOwnProperty('throttle')) {
this._autoThrottle = false;
}
if (this._autoThrottle) {
var globalOption = this.ecModel.option;
this.option.throttle =
(globalOption.animation && globalOption.animationDurationUpdate > 0)
? 100 : 20;
}
},
/**
* @public
*/
......@@ -410,9 +435,9 @@ define(function(require) {
function retrieveRaw(option) {
var ret = {};
each(
['start', 'end', 'startValue', 'endValue'],
['start', 'end', 'startValue', 'endValue', 'throttle'],
function (name) {
ret[name] = option[name];
option.hasOwnProperty(name) && (ret[name] = option[name]);
}
);
return ret;
......
......@@ -41,6 +41,7 @@ define(function (require) {
var allCoordIds = zrUtil.map(coordInfoList, function (coordInfo) {
return roams.generateCoordId(coordInfo.model);
});
zrUtil.each(coordInfoList, function (coordInfo) {
var coordModel = coordInfo.model;
roams.register(
......@@ -50,7 +51,7 @@ define(function (require) {
allCoordIds: allCoordIds,
coordinateSystem: coordModel.coordinateSystem,
dataZoomId: dataZoomModel.id,
throttleRage: dataZoomModel.get('throttle', true),
throttleRate: dataZoomModel.get('throttle', true),
panGetRange: bind(this._onPan, this, coordInfo),
zoomGetRange: bind(this._onZoom, this, coordInfo)
}
......
......@@ -65,13 +65,6 @@ define(function(require) {
textStyle: {
color: '#333'
}
},
/**
* @override
*/
mergeOption: function (option) {
SliderZoomModel.superApply(this, 'mergeOption', arguments);
}
});
......
......@@ -189,8 +189,11 @@ define(function (require) {
resultItem.keyInfo
)
);
// Call optionUpdated after init
componentModel.optionUpdated(newCptOption, true);
// Call optionUpdated after init.
// newCptOption has been used as componentModel.option
// and may be merged with theme and default, so pass null
// to avoid confusion.
componentModel.optionUpdated(null, true);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册