提交 b02066d0 编写于 作者: P pissang

Merge branch 'next' into state

......@@ -810,6 +810,7 @@ class LineView extends ChartView {
if (polygon) {
polygon.setShape({
// Reuse the points with polyline.
points: current,
stackedOnPoints: stackedOnCurrent
});
......@@ -819,8 +820,13 @@ class LineView extends ChartView {
stackedOnPoints: stackedOnNext
}
}, seriesModel);
// If use attr directly in updateProps.
if (polyline.shape.points !== polygon.shape.points) {
polygon.shape.points = polyline.shape.points;
}
}
const updatedDataInfo: {
el: SymbolExtended,
ptIdx: number
......
......@@ -54,9 +54,7 @@ class ParallelView extends ChartView {
seriesModel: ParallelSeriesModel,
ecModel: GlobalModel,
api: ExtensionAPI,
payload: Payload & {
animation?: boolean
}
payload: Payload
) {
const dataGroup = this._dataGroup;
const data = seriesModel.getData();
......@@ -81,8 +79,8 @@ class ParallelView extends ChartView {
const points = createLinePoints(data, newDataIndex, dimensions, coordSys);
data.setItemGraphicEl(newDataIndex, line);
const animationModel = (payload && payload.animation === false) ? null : seriesModel;
graphic.updateProps(line, {shape: {points: points}}, animationModel, newDataIndex);
graphic.updateProps(line, {shape: {points: points}}, seriesModel, newDataIndex);
updateElCommon(line, data, newDataIndex, seriesScope);
}
......
......@@ -103,8 +103,7 @@ class ParallelAxisView extends ComponentView {
builderOpt, areaSelectStyle, axisModel, coordSysModel, areaWidth, api
);
const animationModel = (payload && payload.animation === false) ? null : axisModel;
graphic.groupTransition(oldAxisGroup, this._axisGroup, animationModel);
graphic.groupTransition(oldAxisGroup, this._axisGroup, axisModel);
}
// /**
......
......@@ -46,8 +46,6 @@ echarts.registerAction(actionInfo, function (payload: ParallelAxisAreaSelectPayl
export interface ParallelAxisExpandPayload extends Payload {
axisExpandWindow?: number[];
// Jumping uses animation, and sliding suppresses animation.
animation?: boolean;
}
/**
......
......@@ -752,6 +752,10 @@ class SliderZoomView extends DataZoomView {
type: 'dataZoom',
from: this.uid,
dataZoomId: this.dataZoomModel.id,
animation: {
easing: 'cubicOut',
duration: 100
},
start: range[0],
end: range[1]
});
......
......@@ -181,6 +181,10 @@ function cleanStore(store: Store) {
function dispatchAction(api: ExtensionAPI, batch: DataZoomPayloadBatchItem[]) {
api.dispatchAction({
type: 'dataZoom',
animation: {
easing: 'cubicOut',
duration: 100
},
batch: batch
});
}
......
......@@ -157,7 +157,9 @@ const handlers: Partial<Record<ElementEventName, ElementEventHandler>> = {
: {
axisExpandWindow: result.axisExpandWindow,
// Jumping uses animation, and sliding suppresses animation.
animation: behavior === 'jump' ? null : false
animation: behavior === 'jump' ? null : {
duration: 0 // Disable animation.
}
}
);
}
......
......@@ -1017,7 +1017,13 @@ class ECharts extends Eventful {
this[IN_MAIN_PROCESS_KEY] = true;
optionChanged && prepare(this);
updateMethods.update.call(this);
updateMethods.update.call(this, {
type: 'resize',
animation: {
// Disable animation
duration: 0
}
});
this[IN_MAIN_PROCESS_KEY] = false;
......@@ -1280,6 +1286,8 @@ class ECharts extends Eventful {
): void {
const ecModel = ecIns._model;
ecModel.setUpdatePayload(payload);
// broadcast
if (!mainType) {
// FIXME
......@@ -1377,6 +1385,8 @@ class ECharts extends Eventful {
return;
}
ecModel.setUpdatePayload(payload);
scheduler.restoreData(ecModel, payload);
scheduler.performSeriesTasks(ecModel);
......@@ -1442,6 +1452,8 @@ class ECharts extends Eventful {
return;
}
ecModel.setUpdatePayload(payload);
// ChartView.markUpdateMethod(payload, 'updateTransform');
const componentDirtyList = [];
......@@ -1492,6 +1504,8 @@ class ECharts extends Eventful {
return;
}
ecModel.setUpdatePayload(payload);
ChartView.markUpdateMethod(payload, 'updateView');
clearColorPalette(ecModel);
......@@ -1514,6 +1528,8 @@ class ECharts extends Eventful {
return;
}
ecModel.setUpdatePayload(payload);
// clear all visual
ecModel.eachSeries(function (seriesModel) {
seriesModel.getData().clearAllVisual();
......
......@@ -86,6 +86,11 @@ class GlobalModel extends Model<ECUnitOption> {
*/
private _seriesIndicesMap: HashMap<any>;
/**
* Model for store update payload
*/
private _payload: Payload;
// Injectable properties:
scheduler: Scheduler;
......@@ -318,6 +323,14 @@ class GlobalModel extends Model<ECUnitOption> {
return this._theme;
}
setUpdatePayload(payload: Payload) {
this._payload = payload;
}
getUpdatePayload(): Payload {
return this._payload;
}
/**
* @param idx 0 by default
*/
......
......@@ -58,7 +58,9 @@ import {
ZRStyleProps,
ParsedValue,
BlurScope,
InnerFocus} from './types';
InnerFocus,
AnimationPayload
} from './types';
import { makeInner } from './model';
import {
extend,
......@@ -72,6 +74,7 @@ import SeriesModel from '../model/Series';
import {interpolateNumber} from 'zrender/src/animation/Animator';
import List from '../data/List';
import { getLabelText } from '../label/labelStyle';
import { AnimationEasing } from 'zrender/src/animation/easing';
const mathMax = Math.max;
......@@ -353,32 +356,52 @@ function animateOrSetProps<Props>(
}
const isUpdate = animationType === 'update';
const isRemove = animationType === 'remove';
// Do not check 'animation' property directly here. Consider this case:
// animation model is an `itemModel`, whose does not have `isAnimationEnabled`
// but its parent model (`seriesModel`) does.
let animationPayload: AnimationPayload;
// Check if there is global animation configuration from dataZoom/resize can override the config in option.
// If animation is enabled. Will use this animation config in payload.
// If animation is disabled. Just ignore it.
if (animatableModel && animatableModel.ecModel) {
const updatePayload = animatableModel.ecModel.getUpdatePayload();
animationPayload = (updatePayload && updatePayload.animation) as AnimationPayload;
}
const animationEnabled = animatableModel && animatableModel.isAnimationEnabled();
if (animationEnabled) {
// TODO Configurable
let duration = isRemove ? 200 : animatableModel.getShallow(
isUpdate ? 'animationDurationUpdate' : 'animationDuration'
);
const animationEasing = isRemove ? 'cubicOut' : animatableModel.getShallow(
isUpdate ? 'animationEasingUpdate' : 'animationEasing'
);
let animationDelay = isRemove ? 0 : animatableModel.getShallow(
isUpdate ? 'animationDelayUpdate' : 'animationDelay'
);
if (typeof animationDelay === 'function') {
animationDelay = animationDelay(
dataIndex as number,
animatableModel.getAnimationDelayParams
? animatableModel.getAnimationDelayParams(el, dataIndex as number)
: null
);
let duration: number | Function;
let animationEasing: AnimationEasing;
let animationDelay: number | Function;
if (animationPayload) {
duration = animationPayload.duration || 0;
animationEasing = animationPayload.easing || 'cubicOut';
animationDelay = animationPayload.delay || 0;
}
if (typeof duration === 'function') {
duration = duration(dataIndex as number);
else if (isRemove) {
duration = 200;
animationEasing = 'cubicOut';
animationDelay = 0;
}
else {
duration = animatableModel.getShallow(
isUpdate ? 'animationDurationUpdate' : 'animationDuration'
);
animationEasing = animatableModel.getShallow(
isUpdate ? 'animationEasingUpdate' : 'animationEasing'
);
animationDelay = animatableModel.getShallow(
isUpdate ? 'animationDelayUpdate' : 'animationDelay'
);
if (typeof animationDelay === 'function') {
animationDelay = animationDelay(
dataIndex as number,
animatableModel.getAnimationDelayParams
? animatableModel.getAnimationDelayParams(el, dataIndex as number)
: null
);
}
if (typeof duration === 'function') {
duration = duration(dataIndex as number);
}
}
if (!isRemove) {
......@@ -390,8 +413,8 @@ function animateOrSetProps<Props>(
? (
isFrom
? el.animateFrom(props, {
duration,
delay: animationDelay || 0,
duration: duration as number,
delay: animationDelay as number || 0,
easing: animationEasing,
done: cb,
force: !!cb || !!during,
......@@ -399,8 +422,8 @@ function animateOrSetProps<Props>(
during: during
})
: el.animateTo(props, {
duration,
delay: animationDelay || 0,
duration: duration as number,
delay: animationDelay as number || 0,
easing: animationEasing,
done: cb,
force: !!cb || !!during,
......
......@@ -131,6 +131,7 @@ export interface DataModel extends DataHost, DataFormatMixin {}
interface PayloadItem {
excludeSeriesId?: string | string[];
animation?: AnimationPayload
[other: string]: any;
}
......@@ -140,6 +141,13 @@ export interface Payload extends PayloadItem {
batch?: PayloadItem[];
}
// Payload includes override anmation info
export interface AnimationPayload {
duration?: number
easing?: AnimationEasing
delay?: number
}
export interface ViewRootGroup extends Group {
__ecComponentInfo?: {
mainType: string,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册