You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/06/08 11:49:25 UTC

[incubator-echarts] branch label-enhancement updated: fix(state): fix emphasis toggle too frequently caused color lift accumulation

This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch label-enhancement
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/label-enhancement by this push:
     new eb94696  fix(state): fix emphasis toggle too frequently caused color lift accumulation
eb94696 is described below

commit eb94696f89e1d0779995f47614e6b5da688ec68c
Author: pissang <bm...@gmail.com>
AuthorDate: Mon Jun 8 19:48:49 2020 +0800

    fix(state): fix emphasis toggle too frequently caused color lift accumulation
---
 src/util/graphic.ts | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/util/graphic.ts b/src/util/graphic.ts
index 36d7fd3..fa043c1 100644
--- a/src/util/graphic.ts
+++ b/src/util/graphic.ts
@@ -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;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org