UNPKG

@visactor/vchart

Version:

charts lib based @visactor/VGrammar

180 lines (155 loc) 8.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.registerStageAnimation = exports.registerPolygonAnimation = exports.registerLineOrAreaAnimation = exports.registerArcAnimation = exports.registerRectAnimation = exports.registerBuiltInAnimation = exports.registerAreaAnimation = exports.registerLineAnimation = exports.registerCartesianGroupClipAnimation = exports.registerFadeInOutAnimation = exports.registerScaleInOutAnimation = exports.FadeInOutAnimation = exports.ScaleInOutAnimation = exports.DEFAULT_ANIMATION_CONFIG = void 0; const clip_graphic_1 = require("@visactor/vrender-animate/custom/clip-graphic"), clip_1 = require("@visactor/vrender-animate/custom/clip"), animate_executor_1 = require("@visactor/vrender-animate/executor/animate-executor"), fade_1 = require("@visactor/vrender-animate/custom/fade"), fromTo_1 = require("@visactor/vrender-animate/custom/fromTo"), growAngle_1 = require("@visactor/vrender-animate/custom/growAngle"), growCenter_1 = require("@visactor/vrender-animate/custom/growCenter"), growHeight_1 = require("@visactor/vrender-animate/custom/growHeight"), growPoints_1 = require("@visactor/vrender-animate/custom/growPoints"), growRadius_1 = require("@visactor/vrender-animate/custom/growRadius"), growWidth_1 = require("@visactor/vrender-animate/custom/growWidth"), move_1 = require("@visactor/vrender-animate/custom/move"), rotate_1 = require("@visactor/vrender-animate/custom/rotate"), scale_1 = require("@visactor/vrender-animate/custom/scale"), state_1 = require("@visactor/vrender-animate/custom/state"), tag_points_1 = require("@visactor/vrender-animate/custom/tag-points"), update_1 = require("@visactor/vrender-animate/custom/update"), animation_1 = require("../series/line/animation"), factory_1 = require("../core/factory"), callback_disappear_1 = require("./callback-disappear"), animate_1 = require("../constant/animate"); exports.DEFAULT_ANIMATION_CONFIG = { appear: { duration: 1e3, easing: "cubicOut" }, update: { type: "update", duration: 300, easing: "linear" }, enter: { duration: 300, easing: "linear" }, exit: { duration: 300, easing: "linear" }, disappear: { duration: 500, easing: "cubicIn" }, state: { duration: 300, easing: "linear" } }, exports.ScaleInOutAnimation = { appear: { type: "scaleIn" }, enter: { type: "scaleIn" }, exit: { type: "scaleOut" } }, exports.FadeInOutAnimation = { appear: { type: "fadeIn" }, enter: { type: "fadeIn" }, exit: { type: "fadeOut" } }; const registerScaleInOutAnimation = () => { factory_1.Factory.registerAnimation("scaleInOut", (() => exports.ScaleInOutAnimation)); }; exports.registerScaleInOutAnimation = registerScaleInOutAnimation; const registerFadeInOutAnimation = () => { factory_1.Factory.registerAnimation("fadeInOut", (() => exports.FadeInOutAnimation)); }; exports.registerFadeInOutAnimation = registerFadeInOutAnimation; const registerCartesianGroupClipAnimation = () => { factory_1.Factory.registerAnimation("cartesianGroupClip", (params => ({ appear: { custom: clip_graphic_1.ClipDirectionAnimate, customParameters: (datum, g) => ({ animationType: "in", group: g, direction: params.direction(), width: params.width(), height: params.height(), orient: params.orient() }) } }))); }; exports.registerCartesianGroupClipAnimation = registerCartesianGroupClipAnimation; const lineOrAreaAnimation = (params, preset) => ({ appear: (0, animation_1.linePresetAnimation)(params, preset), enter: { type: "fadeIn" }, exit: { type: "fadeOut" }, update: [ { type: "update", options: { excludeChannels: [ "points", "defined", "segments" ] } }, { channel: [ "points", "segments" ], custom: tag_points_1.TagPointsUpdate, duration: exports.DEFAULT_ANIMATION_CONFIG.update.duration, easing: exports.DEFAULT_ANIMATION_CONFIG.update.easing, customParameters: { clipRangeByDimension: "horizontal" === params.direction ? "y" : "x" } } ] }), registerLineAnimation = () => { factory_1.Factory.registerAnimation("line", lineOrAreaAnimation); }; exports.registerLineAnimation = registerLineAnimation; const registerAreaAnimation = () => { factory_1.Factory.registerAnimation("area", lineOrAreaAnimation); }; exports.registerAreaAnimation = registerAreaAnimation; const registerBuiltInAnimation = () => { animate_executor_1.AnimateExecutor.registerBuiltInAnimate("scaleIn", scale_1.ScaleIn), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("scaleOut", scale_1.ScaleOut), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("fadeIn", fade_1.FadeIn), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("fadeOut", fade_1.FadeOut), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("moveIn", move_1.MoveIn), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("moveOut", move_1.MoveOut), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("rotateIn", rotate_1.RotateIn), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("rotateOut", rotate_1.RotateOut), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("update", update_1.Update), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("state", state_1.State), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("fromTo", fromTo_1.FromTo); }; exports.registerBuiltInAnimation = registerBuiltInAnimation; const registerRectAnimation = () => { animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growHeightIn", growHeight_1.GrowHeightIn), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growHeightOut", growHeight_1.GrowHeightOut), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growWidthIn", growWidth_1.GrowWidthIn), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growWidthOut", growWidth_1.GrowWidthOut), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growCenterIn", growCenter_1.GrowCenterIn), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growCenterOut", growCenter_1.GrowCenterOut); }; exports.registerRectAnimation = registerRectAnimation; const registerArcAnimation = () => { animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growRadiusIn", growRadius_1.GrowRadiusIn), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growRadiusOut", growRadius_1.GrowRadiusOut), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growAngleIn", growAngle_1.GrowAngleIn), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growAngleOut", growAngle_1.GrowAngleOut); }; exports.registerArcAnimation = registerArcAnimation; const registerLineOrAreaAnimation = () => { animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growPointsIn", growPoints_1.GrowPointsIn), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growPointsOut", growPoints_1.GrowPointsOut), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growPointsXIn", growPoints_1.GrowPointsXIn), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growPointsXOut", growPoints_1.GrowPointsXOut), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growPointsYIn", growPoints_1.GrowPointsYIn), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growPointsYOut", growPoints_1.GrowPointsYOut), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("clipIn", clip_1.ClipIn), animate_executor_1.AnimateExecutor.registerBuiltInAnimate("clipOut", clip_1.ClipOut); }; exports.registerLineOrAreaAnimation = registerLineOrAreaAnimation; const registerPolygonAnimation = () => { animate_executor_1.AnimateExecutor.registerBuiltInAnimate("growPointsOut", growPoints_1.GrowPointsOut); }; exports.registerPolygonAnimation = registerPolygonAnimation; const registerStageAnimation = () => { animate_executor_1.AnimateExecutor.registerBuiltInAnimate(animate_1.BuiltIn_DISAPPEAR_ANIMATE_NAME, callback_disappear_1.CallbackDisappearAnimate); }; exports.registerStageAnimation = registerStageAnimation;