@visactor/vrender-animate
Version:
This module provides a graph-based animation system for VRender.
117 lines (106 loc) • 4.71 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.GrowRadiusOut = exports.GrowRadiusIn = exports.GrowPointsBase = exports.growRadiusOut = exports.growRadiusIn = void 0;
const custom_animate_1 = require("./custom-animate"), vutils_1 = require("@visactor/vutils"), growRadiusInIndividual = (graphic, options, animationParameters) => {
const attrs = graphic.getFinalAttribute();
return options && "inside" === options.orient ? {
from: {
innerRadius: null == attrs ? void 0 : attrs.outerRadius
},
to: {
innerRadius: null == attrs ? void 0 : attrs.innerRadius
}
} : {
from: {
outerRadius: null == attrs ? void 0 : attrs.innerRadius
},
to: {
outerRadius: null == attrs ? void 0 : attrs.outerRadius
}
};
}, growRadiusInOverall = (graphic, options, animationParameters) => {
const attrs = graphic.getFinalAttribute(), overallValue = (0, vutils_1.isNumber)(null == options ? void 0 : options.overall) ? options.overall : 0;
return {
from: {
innerRadius: overallValue,
outerRadius: overallValue
},
to: {
innerRadius: null == attrs ? void 0 : attrs.innerRadius,
outerRadius: null == attrs ? void 0 : attrs.outerRadius
}
};
}, growRadiusIn = (graphic, options, animationParameters) => {
var _a;
return !1 !== (null !== (_a = null == options ? void 0 : options.overall) && void 0 !== _a && _a) ? growRadiusInOverall(graphic, options) : growRadiusInIndividual(graphic, options);
};
exports.growRadiusIn = growRadiusIn;
const growRadiusOutIndividual = (graphic, options, animationParameters) => {
const attrs = graphic.getFinalAttribute();
return options && "inside" === options.orient ? {
from: {
innerRadius: null == attrs ? void 0 : attrs.innerRadius
},
to: {
innerRadius: null == attrs ? void 0 : attrs.outerRadius
}
} : {
from: {
outerRadius: null == attrs ? void 0 : attrs.outerRadius
},
to: {
outerRadius: null == attrs ? void 0 : attrs.innerRadius
}
};
}, growRadiusOutOverall = (graphic, options, animationParameters) => {
const attrs = graphic.getFinalAttribute(), overallValue = (0, vutils_1.isNumber)(null == options ? void 0 : options.overall) ? options.overall : 0;
return {
from: {
innerRadius: null == attrs ? void 0 : attrs.innerRadius,
outerRadius: null == attrs ? void 0 : attrs.outerRadius
},
to: {
innerRadius: overallValue,
outerRadius: overallValue
}
};
}, growRadiusOut = (graphic, options, animationParameters) => {
var _a;
return !1 !== (null !== (_a = null == options ? void 0 : options.overall) && void 0 !== _a && _a) ? growRadiusOutOverall(graphic, options) : growRadiusOutIndividual(graphic, options);
};
exports.growRadiusOut = growRadiusOut;
class GrowPointsBase extends custom_animate_1.ACustomAnimate {
constructor(from, to, duration, easing, params) {
super(from, to, duration, easing, params);
}
onUpdate(end, ratio, out) {
const attribute = this.target.attribute;
this.propKeys.forEach((key => {
attribute[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
})), this.target.addUpdatePositionTag(), this.target.addUpdateShapeAndBoundsTag();
}
}
exports.GrowPointsBase = GrowPointsBase;
class GrowRadiusIn extends GrowPointsBase {
onBind() {
var _a, _b;
super.onBind();
const {from: from, to: to} = (0, exports.growRadiusIn)(this.target, this.params.options, this.params), fromAttrs = null !== (_b = null === (_a = this.target.context) || void 0 === _a ? void 0 : _a.lastAttrs) && void 0 !== _b ? _b : from;
this.props = to, this.propKeys = Object.keys(to).filter((key => null != to[key])),
this.from = fromAttrs, this.to = to;
const finalAttribute = this.target.getFinalAttribute();
finalAttribute && this.target.setAttributes(finalAttribute), this.target.setAttributes(fromAttrs);
}
}
exports.GrowRadiusIn = GrowRadiusIn;
class GrowRadiusOut extends GrowPointsBase {
onBind() {
super.onBind();
const {to: to} = (0, exports.growRadiusOut)(this.target, this.params.options, this.params);
this.props = to, this.propKeys = Object.keys(to).filter((key => null != to[key])),
this.from = this.target.attribute, this.to = to;
}
}
exports.GrowRadiusOut = GrowRadiusOut;
//# sourceMappingURL=growRadius.js.map