提交 eb94696f 编写于 作者: P pissang

fix(state): fix emphasis toggle too frequently caused color lift accumulation

上级 73f0a6b6
......@@ -439,6 +439,17 @@ function elementStateProxy(this: Displayable, stateName: string): DisplayableSta
const currentFill = this.style.fill;
const currentStroke = this.style.stroke;
if (currentFill || currentStroke) {
let fromState;
if (!hasEmphasis) {
fromState = {fill: currentFill, stroke: currentStroke};
for (let i = 0; i < this.animators.length; i++) {
const animator = this.animators[i];
if (animator.targetName === 'style') {
animator.saveFinalToTarget(fromState, ['fill', 'stroke']);
}
}
}
state = state || {};
// Apply default color lift
let emphasisStyle = state.style || {};
......@@ -449,14 +460,14 @@ function elementStateProxy(this: Displayable, stateName: string): DisplayableSta
state = extend({}, state);
emphasisStyle = extend({}, emphasisStyle);
// Already being applied 'emphasis'. DON'T lift color multiple times.
emphasisStyle.fill = hasEmphasis ? currentFill : liftColor(currentFill);
emphasisStyle.fill = hasEmphasis ? currentFill : liftColor(fromState.fill);
}
if (!hasFillOrStroke(emphasisStyle.stroke)) {
if (!cloned) {
state = extend({}, state);
emphasisStyle = extend({}, emphasisStyle);
}
emphasisStyle.stroke = hasEmphasis ? currentStroke : liftColor(currentStroke);
emphasisStyle.stroke = hasEmphasis ? currentStroke : liftColor(fromState.stroke);
}
state.style = emphasisStyle;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册