UNPKG

@visactor/vrender-animate

Version:

This module provides a graph-based animation system for VRender.

46 lines (42 loc) 2.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.FromTo = void 0; const constant_1 = require("@visactor/vrender-core/event/constant"), custom_animate_1 = require("./custom-animate"), transient_1 = require("./transient"); class FromTo extends custom_animate_1.ACustomAnimate { constructor(from, to, duration, easing, params) { super(from, to, duration, easing, params), this.from = null != from ? from : {}; } applyTransientFromAttributes() { (0, transient_1.applyAnimationTransientAttributes)(this.target, this.from, constant_1.AttributeUpdateType.ANIMATE_START); } onBind() { var _a, _b, _c; super.onBind(), Object.keys(this.from).forEach((key => { null == this.props[key] && (this.props[key] = this.target.getGraphicAttribute(key)); })), "appear" === (null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.animationState) && this.target.applyFinalAttributeToAttribute(), !1 !== (null === (_c = null === (_b = this.params) || void 0 === _b ? void 0 : _b.controlOptions) || void 0 === _c ? void 0 : _c.immediatelyApply) && this.applyTransientFromAttributes(); } onFirstRun() { this.from = Object.assign(Object.assign({}, this.getLastProps()), this.from); const startProps = this.animate.getStartProps(); this.propKeys && this.propKeys.forEach((key => { var _a; this.from[key] = null !== (_a = this.from[key]) && void 0 !== _a ? _a : startProps[key]; })), this.applyTransientFromAttributes(); } deleteSelfAttr(key) { this.deleteSelfAttrs([ key ]); } deleteSelfAttrs(keys) { super.deleteSelfAttrs(keys), this.from = this.removeKeysFromRecord(this.from, keys); } update(end, ratio, out) { if (this.onStart(), !this.props || !this.propKeys) return; const easedRatio = this.easing(ratio); this.runInterpolateUpdate(this.from, this.props, easedRatio), this.onUpdate(end, easedRatio, out), this.syncAttributeUpdate(); } } exports.FromTo = FromTo; //# sourceMappingURL=fromTo.js.map