diff --git a/packages/f2-next/src/canvas/animation/index.ts b/packages/f2-next/src/canvas/animation/index.ts index c72e462b4..509c2db60 100644 --- a/packages/f2-next/src/canvas/animation/index.ts +++ b/packages/f2-next/src/canvas/animation/index.ts @@ -33,7 +33,7 @@ class Animation { return new Animator(element, animation); } - play(container) { + play(container, onAnimationEnd) { const { canvas } = this; const animators: Animator[] = []; let maxDuration = 0; @@ -95,6 +95,7 @@ class Animation { element.remove(true); } canvas.draw(); + onAnimationEnd && onAnimationEnd(); }) } diff --git a/packages/f2-next/src/canvas/index.ts b/packages/f2-next/src/canvas/index.ts index d1db99f14..ef2faf223 100644 --- a/packages/f2-next/src/canvas/index.ts +++ b/packages/f2-next/src/canvas/index.ts @@ -94,11 +94,12 @@ class Canvas extends Component implements IF2Canvas { } draw() { - const { canvas, container, animation } = this; + const { canvas, container, animation, props } = this; + const { onAnimationEnd } = props; // 执行动画 if (animation) { animation.abort(); - animation.play(container); + animation.play(container, onAnimationEnd); } else { canvas.draw(); } @@ -125,9 +126,10 @@ class Canvas extends Component implements IF2Canvas { const componentTree = createComponentTree(children, { canvas: this, width, height, context, layout }); - if (equal(this.componentTree, componentTree)) { - return; - } + + // if (equal(this.componentTree, componentTree)) { + // return; + // } component.update({ children: componentTree }); this.render(); diff --git a/packages/f2-next/src/chart/index.ts b/packages/f2-next/src/chart/index.ts index f629db64d..be343daaa 100644 --- a/packages/f2-next/src/chart/index.ts +++ b/packages/f2-next/src/chart/index.ts @@ -257,4 +257,6 @@ class Chart extends Container implements IChart, ThemeMixin, CoordMixin, ScaleMi // 多继承 applyMixins(Chart, [ ThemeMixin, CoordMixin, ScaleMixin ]); -export default Chart; +class ExportChart extends Chart {} + +export default ExportChart; diff --git a/packages/f2-next/src/components/guide/withGuide.tsx b/packages/f2-next/src/components/guide/withGuide.tsx index 8022e87c0..7b304f1d0 100644 --- a/packages/f2-next/src/components/guide/withGuide.tsx +++ b/packages/f2-next/src/components/guide/withGuide.tsx @@ -23,7 +23,7 @@ export default (View) => { canvas.on("click", (ev) => { const { points } = ev; const shape = this.triggerRef.current; - if (!shape) return; + if (!shape || shape.isDestroyed()) return; const bbox = shape.getBBox(); if (isInBBox(bbox, points[0])) { ev.shape = shape; @@ -81,6 +81,10 @@ export default (View) => { return coord.convertPoint({ x, y }); } + convertPoints(records) { + return records.map((record) => this.parsePoint(record)); + } + getGuideTheme() { const { theme } = this.chart; return theme['guide']; @@ -90,7 +94,7 @@ export default (View) => { const { props, chart } = this; const { records = [] } = props; const { coord } = chart; - const points = records.map((record) => this.parsePoint(record)); + const points = this.convertPoints(records); const theme = this.getGuideTheme(); return