提交 3a80a47a 编写于 作者: P pissang

fix(toolbox): fix icon emphasis status not keep when selected.

上级 eb94696f
...@@ -143,8 +143,9 @@ class ToolboxView extends ComponentView { ...@@ -143,8 +143,9 @@ class ToolboxView extends ComponentView {
const iconPaths = this.iconPaths; const iconPaths = this.iconPaths;
option.iconStatus = option.iconStatus || {}; option.iconStatus = option.iconStatus || {};
option.iconStatus[iconName] = status; option.iconStatus[iconName] = status;
// FIXME if (iconPaths[iconName]) {
iconPaths[iconName] && iconPaths[iconName].trigger(status); graphic[status === 'emphasis' ? 'enterEmphasis' : 'leaveEmphasis'](iconPaths[iconName]);
}
}; };
if (feature instanceof ToolboxFeature) { if (feature instanceof ToolboxFeature) {
...@@ -240,31 +241,40 @@ class ToolboxView extends ComponentView { ...@@ -240,31 +241,40 @@ class ToolboxView extends ComponentView {
}, tooltipModel.option); }, tooltipModel.option);
} }
graphic.enableHoverEmphasis(path); // graphic.enableHoverEmphasis(path);
if (toolboxModel.get('showTitle')) { (path as ExtendedPath).__title = titlesMap[iconName];
(path as ExtendedPath).__title = titlesMap[iconName]; (path as graphic.Path).on('mouseover', function () {
(path as graphic.Path).on('mouseover', function () { // Should not reuse above hoverStyle, which might be modified.
// Should not reuse above hoverStyle, which might be modified. const hoverStyle = iconStyleEmphasisModel.getItemStyle();
const hoverStyle = iconStyleEmphasisModel.getItemStyle(); const defaultTextPosition = toolboxModel.get('orient') === 'vertical'
const defaultTextPosition = toolboxModel.get('orient') === 'vertical' ? (toolboxModel.get('right') == null ? 'right' as const : 'left' as const)
? (toolboxModel.get('right') == null ? 'right' as const : 'left' as const) : (toolboxModel.get('bottom') == null ? 'bottom' as const : 'top' as const);
: (toolboxModel.get('bottom') == null ? 'bottom' as const : 'top' as const); textContent.setStyle({
textContent.setStyle({ fill: (iconStyleEmphasisModel.get('textFill')
fill: (iconStyleEmphasisModel.get('textFill') || hoverStyle.fill || hoverStyle.stroke || '#000') as string,
|| hoverStyle.fill || hoverStyle.stroke || '#000') as string, backgroundColor: iconStyleEmphasisModel.get('textBackgroundColor')
backgroundColor: iconStyleEmphasisModel.get('textBackgroundColor')
});
path.setTextConfig({
position: iconStyleEmphasisModel.get('textPosition') || defaultTextPosition
});
textContent.ignore = false;
})
.on('mouseout', function () {
textContent.ignore = true;
}); });
} path.setTextConfig({
path.trigger(featureModel.get(['iconStatus', iconName]) || 'normal'); position: iconStyleEmphasisModel.get('textPosition') || defaultTextPosition
});
textContent.ignore = !toolboxModel.get('showTitle');
// Use enterEmphasis and leaveEmphasis provide by ec.
// There are flags managed by the echarts.
graphic.enterEmphasis(this);
})
.on('mouseout', function () {
if (featureModel.get(['iconStatus', iconName]) !== 'emphasis') {
graphic.leaveEmphasis(this);
}
textContent.hide();
});
graphic[
featureModel.get(['iconStatus', iconName]) === 'emphasis'
? 'enterEmphasis' : 'leaveEmphasis'
](path);
group.add(path); group.add(path);
(path as graphic.Path).on('click', zrUtil.bind( (path as graphic.Path).on('click', zrUtil.bind(
......
...@@ -1668,10 +1668,10 @@ class ECharts extends Eventful { ...@@ -1668,10 +1668,10 @@ class ECharts extends Eventful {
): void { ): void {
each(dirtyList || ecIns._componentsViews, function (componentView: ComponentView) { each(dirtyList || ecIns._componentsViews, function (componentView: ComponentView) {
const componentModel = componentView.__model; const componentModel = componentView.__model;
componentView.render(componentModel, ecModel, api, payload);
clearStates(componentModel, componentView); clearStates(componentModel, componentView);
componentView.render(componentModel, ecModel, api, payload);
updateZ(componentModel, componentView); updateZ(componentModel, componentView);
updateHoverEmphasisHandler(componentView); updateHoverEmphasisHandler(componentView);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册