提交 97e15ec4 编写于 作者: P pissang

fix(animation): force stop remove animation before init again.

上级 f6c5bef9
...@@ -28,7 +28,8 @@ import { ...@@ -28,7 +28,8 @@ import {
enableHoverEmphasis, enableHoverEmphasis,
setLabelStyle, setLabelStyle,
updateLabel, updateLabel,
initLabel initLabel,
removeElement
} from '../../util/graphic'; } from '../../util/graphic';
import Path, { PathProps } from 'zrender/src/graphic/Path'; import Path, { PathProps } from 'zrender/src/graphic/Path';
import Group from 'zrender/src/graphic/Group'; import Group from 'zrender/src/graphic/Group';
...@@ -703,7 +704,7 @@ function removeRect( ...@@ -703,7 +704,7 @@ function removeRect(
) { ) {
// Not show text when animating // Not show text when animating
el.removeTextContent(); el.removeTextContent();
updateProps(el, { removeElement(el, {
style: { style: {
opacity: 0 opacity: 0
} }
...@@ -719,7 +720,7 @@ function removeSector( ...@@ -719,7 +720,7 @@ function removeSector(
) { ) {
// Not show text when animating // Not show text when animating
el.removeTextContent(); el.removeTextContent();
updateProps(el, { removeElement(el, {
style: { style: {
opacity: 0 opacity: 0
} }
......
...@@ -869,7 +869,7 @@ function removeBar( ...@@ -869,7 +869,7 @@ function removeBar(
bar.__pictorialClipPath && (animationModel = null); bar.__pictorialClipPath && (animationModel = null);
zrUtil.each(pathes, function (path) { zrUtil.each(pathes, function (path) {
graphic.updateProps( graphic.removeElement(
path, { scaleX: 0, scaleY: 0 }, animationModel, dataIndex, path, { scaleX: 0, scaleY: 0 }, animationModel, dataIndex,
function () { function () {
bar.parent && bar.parent.remove(bar); bar.parent && bar.parent.remove(bar);
......
...@@ -169,20 +169,18 @@ class Symbol extends graphic.Group { ...@@ -169,20 +169,18 @@ class Symbol extends graphic.Group {
if (isInit) { if (isInit) {
const symbolPath = this.childAt(0) as ECSymbol; const symbolPath = this.childAt(0) as ECSymbol;
// Always fadeIn. Because it has fadeOut animation when symbol is removed..
// const fadeIn = seriesScope && seriesScope.fadeIn;
const fadeIn = true;
const target: PathProps = { const target: PathProps = {
scaleX: this._sizeX, scaleX: this._sizeX,
scaleY: this._sizeY scaleY: this._sizeY,
}; style: {
fadeIn && (target.style = { // Always fadeIn. Because it has fadeOut animation when symbol is removed..
opacity: symbolPath.style.opacity opacity: symbolPath.style.opacity
}); }
};
symbolPath.scaleX = symbolPath.scaleY = 0; symbolPath.scaleX = symbolPath.scaleY = 0;
fadeIn && (symbolPath.style.opacity = 0); symbolPath.style.opacity = 0;
graphic.initProps(symbolPath, target, seriesModel, idx); graphic.initProps(symbolPath, target, seriesModel, idx);
} }
...@@ -311,7 +309,7 @@ class Symbol extends graphic.Group { ...@@ -311,7 +309,7 @@ class Symbol extends graphic.Group {
// Not show text when animating // Not show text when animating
!(opt && opt.keepLabel) && (symbolPath.removeTextContent()); !(opt && opt.keepLabel) && (symbolPath.removeTextContent());
graphic.updateProps( graphic.removeElement(
symbolPath, symbolPath,
{ {
style: { style: {
......
...@@ -53,6 +53,7 @@ export interface LineDataItemOption extends SymbolOptionMixin { ...@@ -53,6 +53,7 @@ export interface LineDataItemOption extends SymbolOptionMixin {
} }
} }
export interface LineSeriesOption extends SeriesOption, export interface LineSeriesOption extends SeriesOption,
SeriesOnCartesianOptionMixin, SeriesOnCartesianOptionMixin,
SeriesOnPolarOptionMixin, SeriesOnPolarOptionMixin,
......
...@@ -501,7 +501,7 @@ class LineView extends ChartView { ...@@ -501,7 +501,7 @@ class LineView extends ChartView {
// Stop symbol animation and sync with line points // Stop symbol animation and sync with line points
// FIXME performance? // FIXME performance?
data.eachItemGraphicEl(function (el) { data.eachItemGraphicEl(function (el) {
el.stopAnimation(true); el.stopAnimation('', true);
}); });
// In the case data zoom triggerred refreshing frequently // In the case data zoom triggerred refreshing frequently
......
...@@ -795,7 +795,7 @@ function pointerMoveTo( ...@@ -795,7 +795,7 @@ function pointerMoveTo(
pointer.y = 0; pointer.y = 0;
} }
else { else {
pointer.stopAnimation(true); pointer.stopAnimation('', true);
pointer.animateTo({ pointer.animateTo({
x: toCoord, x: toCoord,
y: 0 y: 0
......
...@@ -554,7 +554,7 @@ class ECharts extends Eventful { ...@@ -554,7 +554,7 @@ class ECharts extends Eventful {
const list = zr.storage.getDisplayList(); const list = zr.storage.getDisplayList();
// Stop animations // Stop animations
zrUtil.each(list, function (el: Element) { zrUtil.each(list, function (el: Element) {
el.stopAnimation(true); el.stopAnimation('', true);
}); });
return (zr.painter as SVGPainter).toDataURL(); return (zr.painter as SVGPainter).toDataURL();
......
...@@ -688,7 +688,7 @@ type LabelModelForText = Model<Omit< ...@@ -688,7 +688,7 @@ type LabelModelForText = Model<Omit<
}>; }>;
function getLabelText<LDI>( function getLabelText<LDI>(
opt?: SetLabelStyleOpt<LDI>, opt: SetLabelStyleOpt<LDI>,
normalModel: LabelModel, normalModel: LabelModel,
emphasisModel: LabelModel, emphasisModel: LabelModel,
interpolateValues?: ParsedValue | ParsedValue[] interpolateValues?: ParsedValue | ParsedValue[]
...@@ -1136,7 +1136,7 @@ type AnimateOrSetPropsOption = { ...@@ -1136,7 +1136,7 @@ type AnimateOrSetPropsOption = {
}; };
function animateOrSetProps<Props>( function animateOrSetProps<Props>(
isUpdate: boolean, animationType: 'init' | 'update' | 'remove',
el: Element<Props>, el: Element<Props>,
props: Props, props: Props,
animatableModel?: Model<AnimationOptionMixin> & { animatableModel?: Model<AnimationOptionMixin> & {
...@@ -1158,19 +1158,22 @@ function animateOrSetProps<Props>( ...@@ -1158,19 +1158,22 @@ function animateOrSetProps<Props>(
isFrom = dataIndex.isFrom; isFrom = dataIndex.isFrom;
dataIndex = dataIndex.dataIndex; dataIndex = dataIndex.dataIndex;
} }
const isUpdate = animationType === 'update';
const isRemove = animationType === 'remove';
// Do not check 'animation' property directly here. Consider this case: // Do not check 'animation' property directly here. Consider this case:
// animation model is an `itemModel`, whose does not have `isAnimationEnabled` // animation model is an `itemModel`, whose does not have `isAnimationEnabled`
// but its parent model (`seriesModel`) does. // but its parent model (`seriesModel`) does.
const animationEnabled = animatableModel && animatableModel.isAnimationEnabled(); const animationEnabled = animatableModel && animatableModel.isAnimationEnabled();
if (animationEnabled) { if (animationEnabled) {
let duration = animatableModel.getShallow( // TODO Configurable
let duration = isRemove ? 200 : animatableModel.getShallow(
isUpdate ? 'animationDurationUpdate' : 'animationDuration' isUpdate ? 'animationDurationUpdate' : 'animationDuration'
); );
const animationEasing = animatableModel.getShallow( const animationEasing = isRemove ? 'cubicOut' : animatableModel.getShallow(
isUpdate ? 'animationEasingUpdate' : 'animationEasing' isUpdate ? 'animationEasingUpdate' : 'animationEasing'
); );
let animationDelay = animatableModel.getShallow( let animationDelay = isRemove ? 0 : animatableModel.getShallow(
isUpdate ? 'animationDelayUpdate' : 'animationDelay' isUpdate ? 'animationDelayUpdate' : 'animationDelay'
); );
if (typeof animationDelay === 'function') { if (typeof animationDelay === 'function') {
...@@ -1185,6 +1188,11 @@ function animateOrSetProps<Props>( ...@@ -1185,6 +1188,11 @@ function animateOrSetProps<Props>(
duration = duration(dataIndex as number); duration = duration(dataIndex as number);
} }
if (!isRemove) {
// Must stop the remove animation.
el.stopAnimation('remove');
}
duration > 0 duration > 0
? ( ? (
isFrom isFrom
...@@ -1194,6 +1202,7 @@ function animateOrSetProps<Props>( ...@@ -1194,6 +1202,7 @@ function animateOrSetProps<Props>(
easing: animationEasing, easing: animationEasing,
done: cb, done: cb,
force: !!cb || !!during, force: !!cb || !!during,
scope: animationType,
during: during during: during
}) })
: el.animateTo(props, { : el.animateTo(props, {
...@@ -1203,6 +1212,7 @@ function animateOrSetProps<Props>( ...@@ -1203,6 +1212,7 @@ function animateOrSetProps<Props>(
done: cb, done: cb,
force: !!cb || !!during, force: !!cb || !!during,
setToFinal: true, setToFinal: true,
scope: animationType,
during: during during: during
}) })
) )
...@@ -1240,7 +1250,7 @@ function updateProps<Props>( ...@@ -1240,7 +1250,7 @@ function updateProps<Props>(
cb?: AnimateOrSetPropsOption['cb'] | AnimateOrSetPropsOption['during'], cb?: AnimateOrSetPropsOption['cb'] | AnimateOrSetPropsOption['during'],
during?: AnimateOrSetPropsOption['during'] during?: AnimateOrSetPropsOption['during']
) { ) {
animateOrSetProps(true, el, props, animatableModel, dataIndex, cb, during); animateOrSetProps('update', el, props, animatableModel, dataIndex, cb, during);
} }
export {updateProps}; export {updateProps};
...@@ -1261,7 +1271,21 @@ export function initProps<Props>( ...@@ -1261,7 +1271,21 @@ export function initProps<Props>(
cb?: AnimateOrSetPropsOption['cb'] | AnimateOrSetPropsOption['during'], cb?: AnimateOrSetPropsOption['cb'] | AnimateOrSetPropsOption['during'],
during?: AnimateOrSetPropsOption['during'] during?: AnimateOrSetPropsOption['during']
) { ) {
animateOrSetProps(false, el, props, animatableModel, dataIndex, cb, during); animateOrSetProps('init', el, props, animatableModel, dataIndex, cb, during);
}
/**
* Remove graphic element
*/
export function removeElement<Props>(
el: Element<Props>,
props: Props,
animatableModel?: Model<AnimationOptionMixin>,
dataIndex?: AnimateOrSetPropsOption['dataIndex'] | AnimateOrSetPropsOption['cb'] | AnimateOrSetPropsOption,
cb?: AnimateOrSetPropsOption['cb'] | AnimateOrSetPropsOption['during'],
during?: AnimateOrSetPropsOption['during']
) {
animateOrSetProps('remove', el, props, animatableModel, dataIndex, cb, during);
} }
function animateOrSetLabel<Props extends PathProps>( function animateOrSetLabel<Props extends PathProps>(
...@@ -1278,7 +1302,7 @@ function animateOrSetLabel<Props extends PathProps>( ...@@ -1278,7 +1302,7 @@ function animateOrSetLabel<Props extends PathProps>(
const valueAnimationEnabled = labelModel && labelModel.get('valueAnimation'); const valueAnimationEnabled = labelModel && labelModel.get('valueAnimation');
if (valueAnimationEnabled) { if (valueAnimationEnabled) {
const precisionOption = labelModel.get('precision'); const precisionOption = labelModel.get('precision');
let precision: number = precisionOption === 'auto' ? 0 : precisionOption; const precision: number = precisionOption === 'auto' ? 0 : precisionOption;
let interpolateValues: (number | string)[] | (number | string); let interpolateValues: (number | string)[] | (number | string);
const rawValues = seriesModel.getRawValue(dataIndex); const rawValues = seriesModel.getRawValue(dataIndex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册