UNPKG

react-native-reanimated

Version:

More powerful alternative to Animated library for React Native.

68 lines (55 loc) 2.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SequencedTransition = void 0; var _animation = require("../../animation"); var _animationBuilder = require("../animationBuilder"); function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } class SequencedTransition extends _animationBuilder.BaseAnimationBuilder { constructor() { super(...arguments); _defineProperty(this, "reversed", false); _defineProperty(this, "build", () => { const delayFunction = this.getDelayFunction(); const callback = this.callbackV; const delay = this.getDelay(); const sequenceDuration = (this.durationV ?? 500) / 2; const config = { duration: sequenceDuration }; const reverse = this.reversed; return values => { 'worklet'; return { initialValues: { originX: values.currentOriginX, originY: values.currentOriginY, width: values.currentWidth, height: values.currentHeight }, animations: { originX: delayFunction(delay, (0, _animation.withSequence)((0, _animation.withTiming)(reverse ? values.currentOriginX : values.targetOriginX, config), (0, _animation.withTiming)(values.targetOriginX, config))), originY: delayFunction(delay, (0, _animation.withSequence)((0, _animation.withTiming)(reverse ? values.targetOriginY : values.currentOriginY, config), (0, _animation.withTiming)(values.targetOriginY, config))), width: delayFunction(delay, (0, _animation.withSequence)((0, _animation.withTiming)(reverse ? values.currentWidth : values.targetWidth, config), (0, _animation.withTiming)(values.targetWidth, config))), height: delayFunction(delay, (0, _animation.withSequence)((0, _animation.withTiming)(reverse ? values.targetHeight : values.currentHeight, config), (0, _animation.withTiming)(values.targetHeight, config))) }, callback: callback }; }; }); } static createInstance() { return new SequencedTransition(); } static reverse() { const instance = SequencedTransition.createInstance(); return instance.reverse(); } reverse() { this.reversed = !this.reversed; return this; } } exports.SequencedTransition = SequencedTransition; //# sourceMappingURL=SequencedTransition.js.map