UNPKG

timered-counter

Version:

Make the value change more vivid and natural

55 lines 2.45 kB
import { __decorate } from "tslib"; import { property } from 'lit/decorators.js'; import { isDeepEqual } from 'remeda'; import { extractPartDigitOption, mergePartDigitOption, } from '../utils/extract-group-option.js'; export const CounterAnimationMixin = (superClass) => { class CounterAnimationMixinClass extends superClass { constructor() { super(...arguments); /** * 传递给 Web Animations API 的选项. */ this.animationOptions = {}; this.cachedAnimationOptions = []; /** * 传递给 Web Animations API 的关键帧配置. */ this.keyframes = {}; this.cachedKeyframes = []; } extractAnimationOptions() { const getterOptions = { preprocessData: this.partPreprocessDataList, data: this.parts, direction: this.direction, value: [this.value, this.oldValue], }; const result = mergePartDigitOption(extractPartDigitOption(this.animationOptions ?? {}, getterOptions), extractPartDigitOption(this.animationOptionsDynamic ?? {}, getterOptions)); if (!isDeepEqual(this.cachedAnimationOptions, result)) { this.cachedAnimationOptions = result; } return this.cachedAnimationOptions; } extractKeyframes() { const getterOptions = { preprocessData: this.partPreprocessDataList, data: this.parts, direction: this.direction, value: [this.value, this.oldValue], }; const result = mergePartDigitOption(extractPartDigitOption(this.keyframes ?? {}, getterOptions), extractPartDigitOption(this.keyframesDynamic ?? {}, getterOptions)); if (!isDeepEqual(this.cachedKeyframes, result)) { this.cachedKeyframes = result; } return this.cachedKeyframes; } } __decorate([ property({ type: Object, attribute: 'animation-options', reflect: true }) ], CounterAnimationMixinClass.prototype, "animationOptions", void 0); __decorate([ property({ type: Object, attribute: 'keyframes', reflect: true }) ], CounterAnimationMixinClass.prototype, "keyframes", void 0); return CounterAnimationMixinClass; }; //# sourceMappingURL=counter-animation.js.map