UNPKG

@tamagui/react-native-web-lite

Version:
68 lines (67 loc) 3.1 kB
import NativeAnimatedHelper from "../NativeAnimatedHelper.native.js"; function _class_call_check(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor); } } function _create_class(Constructor, protoProps, staticProps) { return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), Constructor; } function _define_property(obj, key, value) { return key in obj ? Object.defineProperty(obj, key, { value, enumerable: !0, configurable: !0, writable: !0 }) : obj[key] = value, obj; } var startNativeAnimationNextId = 1, Animation = /* @__PURE__ */function () { function Animation2() { _class_call_check(this, Animation2), _define_property(this, "__active", void 0), _define_property(this, "__isInteraction", void 0), _define_property(this, "__nativeId", void 0), _define_property(this, "__onEnd", void 0), _define_property(this, "__iterations", void 0); } return _create_class(Animation2, [{ key: "start", value: function (fromValue, onUpdate, onEnd, previousAnimation, animatedValue) {} }, { key: "stop", value: function () { this.__nativeId && NativeAnimatedHelper.API.stopAnimation(this.__nativeId); } }, { key: "__getNativeAnimationConfig", value: function () { throw new Error("This animation type cannot be offloaded to native"); } }, { // Helper function for subclasses to make sure onEnd is only called once. key: "__debouncedOnEnd", value: function (result) { var onEnd = this.__onEnd; this.__onEnd = null, onEnd && onEnd(result); } }, { key: "__startNativeAnimation", value: function (animatedValue) { var startNativeAnimationWaitId = `${startNativeAnimationNextId}:startAnimation`; startNativeAnimationNextId += 1, NativeAnimatedHelper.API.setWaitingForIdentifier(startNativeAnimationWaitId); try { var config = this.__getNativeAnimationConfig(); animatedValue.__makeNative(config.platformConfig), this.__nativeId = NativeAnimatedHelper.generateNewAnimationId(), NativeAnimatedHelper.API.startAnimatingNode(this.__nativeId, animatedValue.__getNativeTag(), config, // $FlowFixMe[method-unbinding] added when improving typing for this parameters this.__debouncedOnEnd.bind(this)); } catch (e) { throw e; } finally { NativeAnimatedHelper.API.unsetWaitingForIdentifier(startNativeAnimationWaitId); } } }]), Animation2; }(), Animation_default = Animation; export { Animation_default as default }; //# sourceMappingURL=Animation.native.js.map