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/09 08:54:23 UTC
[incubator-echarts] branch label-enhancement updated: fix(state):
fix last commit, still needs save,
clear and restore states without animation.
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 dd37d60 fix(state): fix last commit, still needs save, clear and restore states without animation.
dd37d60 is described below
commit dd37d60aaab640743fea49bba2d476ddd3fce3cb
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Jun 9 16:53:54 2020 +0800
fix(state): fix last commit, still needs save, clear and restore states without animation.
---
src/echarts.ts | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/echarts.ts b/src/echarts.ts
index 0d16014..13fc68c 100644
--- a/src/echarts.ts
+++ b/src/echarts.ts
@@ -1826,15 +1826,13 @@ class ECharts extends Eventful {
});
};
+ interface DisplayableWithStatesHistory extends Displayable {
+ __prevStates: string[]
+ };
// Clear states without animation.
// TODO States on component.
function clearStates(model: ComponentModel, view: ComponentView | ChartView): void {
view.group.traverse(function (el: Displayable) {
- // TODO If el is incremental.
- if (el.hasState()) {
- el.clearStates();
- }
-
const textContent = el.getTextContent();
const textGuide = el.getTextGuideLine();
if (el.stateTransition) {
@@ -1846,6 +1844,15 @@ class ECharts extends Eventful {
if (textGuide && textGuide.stateTransition) {
textGuide.stateTransition = null;
}
+
+ // TODO If el is incremental.
+ if (el.hasState()) {
+ (el as DisplayableWithStatesHistory).__prevStates = el.currentStates;
+ el.clearStates();
+ }
+ else if ((el as DisplayableWithStatesHistory).__prevStates) {
+ (el as DisplayableWithStatesHistory).__prevStates = null;
+ }
});
}
@@ -1855,6 +1862,12 @@ class ECharts extends Eventful {
view.group.traverse(function (el: Displayable) {
// Only updated on changed element. In case element is incremental and don't wan't to rerender.
if (el.__dirty && el.states && el.states.emphasis) {
+ const prevStates = (el as DisplayableWithStatesHistory).__prevStates;
+ // Restore states without animation
+ if (prevStates) {
+ el.useStates(prevStates);
+ }
+
// Update state transition and enable animation again.
if (enableAnimation) {
graphic.setStateTransition(el, stateAnimationModel);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org