UNPKG

@visactor/vchart

Version:

charts lib based @visactor/VGrammar

47 lines (38 loc) 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.registerWordCloudAnimation = exports.wordcloudPresetAnimation = exports.WordCloudScaleInAnimation = void 0; const config_1 = require("../../animation/config"), factory_1 = require("../../core/factory"); function computeWordDelay(duration, totalTime, wordCount) { return duration * wordCount < totalTime ? duration + (totalTime - wordCount * duration) / (wordCount - 1) : (totalTime - duration) / (wordCount - 1); } const WordCloudScaleInAnimation = params => ({ type: "scaleIn", duration: 200, delay: (datum, graphic) => { const animationConfig = params.animationConfig(), duration = (null == animationConfig ? void 0 : animationConfig.duration) || 200, totalTime = (null == animationConfig ? void 0 : animationConfig.totalTime) || config_1.DEFAULT_ANIMATION_CONFIG.appear.duration, count = graphic.context.graphicCount; return graphic.context.graphicIndex * computeWordDelay(duration, totalTime, count); } }); function wordcloudPresetAnimation(params, preset) { return !1 === preset ? {} : "fadeIn" === preset ? { type: "fadeIn" } : (0, exports.WordCloudScaleInAnimation)(params); } exports.WordCloudScaleInAnimation = WordCloudScaleInAnimation, exports.wordcloudPresetAnimation = wordcloudPresetAnimation; const registerWordCloudAnimation = () => { factory_1.Factory.registerAnimation("wordCloud", ((params, preset) => ({ appear: wordcloudPresetAnimation(params, preset), enter: { type: "fadeIn" }, exit: { type: "fadeOut" }, disappear: { type: "fadeOut" } }))); }; exports.registerWordCloudAnimation = registerWordCloudAnimation; //# sourceMappingURL=animation.js.map