UNPKG

@antv/f2

Version:

Charts for mobile visualization.

36 lines 1.52 kB
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2"; import { ELEMENT_DELETE } from '../elementStatus'; import createClipElement from '../createClipElement'; import { isFunction } from '@antv/util'; export default (function (element, animation, nextAttrs, lastAttrs) { if (!animation) return null; // 获取shape的默认属性 var status = element.get('status'); var clip = animation.clip, start = animation.start, end = animation.end, easing = animation.easing, delay = animation.delay, duration = animation.duration; var clipConfig = isFunction(clip) ? clip(element._attrs.attrs) : clip; // 裁剪动画 if (clipConfig) { var type = clipConfig.type, attrs = clipConfig.attrs, clipStart = clipConfig.start; var clipElement = createClipElement(type, { attrs: _objectSpread(_objectSpread({}, attrs), clipStart) }); // 默认用 animation 配置里的 easing 和 duration clipConfig.easing = clipConfig.easing || easing; clipConfig.delay = typeof clipConfig.delay === 'number' ? clipConfig.delay : delay; clipConfig.duration = clipConfig.duration || duration; clipConfig.element = clipElement; } var defaultAttrs = element.getDefaultAttrs(); return _objectSpread(_objectSpread({}, animation), {}, { clip: clipConfig, start: _objectSpread(_objectSpread(_objectSpread({}, defaultAttrs), lastAttrs), start), end: _objectSpread(_objectSpread({}, status === ELEMENT_DELETE ? null : nextAttrs), end) }); });