@tamagui/react-native-web-lite
Version:
React Native for Web
114 lines (113 loc) • 3.38 kB
JavaScript
import { AnimatedEvent, attachNativeEvent } from "./AnimatedEvent.mjs";
import AnimatedImplementation from "./AnimatedImplementation.mjs";
import createAnimatedComponent from "./createAnimatedComponent.mjs";
import AnimatedColor from "./nodes/AnimatedColor.mjs";
import AnimatedInterpolation from "./nodes/AnimatedInterpolation.mjs";
import AnimatedNode from "./nodes/AnimatedNode.mjs";
import AnimatedValue from "./nodes/AnimatedValue.mjs";
import AnimatedValueXY from "./nodes/AnimatedValueXY.mjs";
var inAnimationCallback = !1;
function mockAnimationStart(start) {
return callback => {
var guardedCallback = callback == null ? callback : function () {
if (inAnimationCallback) {
console.warn("Ignoring recursive animation callback when running mock animations");
return;
}
inAnimationCallback = !0;
try {
callback(...arguments);
} finally {
inAnimationCallback = !1;
}
};
start(guardedCallback);
};
}
var emptyAnimation = {
start: () => {},
stop: () => {},
reset: () => {},
_startNativeLoop: () => {},
_isUsingNativeDriver: () => !1
},
mockCompositeAnimation = animations => ({
...emptyAnimation,
start: mockAnimationStart(callback => {
animations.forEach(animation => animation.start()), callback?.({
finished: !0
});
})
}),
spring = function (value, config) {
var anyValue = value;
return {
...emptyAnimation,
start: mockAnimationStart(callback => {
anyValue.setValue(config.toValue), callback?.({
finished: !0
});
})
};
},
timing = function (value, config) {
var anyValue = value;
return {
...emptyAnimation,
start: mockAnimationStart(callback => {
anyValue.setValue(config.toValue), callback?.({
finished: !0
});
})
};
},
decay = function (value, config) {
return emptyAnimation;
},
sequence = function (animations) {
return mockCompositeAnimation(animations);
},
parallel = function (animations, config) {
return mockCompositeAnimation(animations);
},
delay = function (time) {
return emptyAnimation;
},
stagger = function (time, animations) {
return mockCompositeAnimation(animations);
},
loop = function (animation, _temp) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$iterations = _ref.iterations,
iterations = _ref$iterations === void 0 ? -1 : _ref$iterations;
return emptyAnimation;
},
AnimatedMock_default = {
Value: AnimatedValue,
ValueXY: AnimatedValueXY,
Color: AnimatedColor,
Interpolation: AnimatedInterpolation,
Node: AnimatedNode,
decay,
timing,
spring,
add: AnimatedImplementation.add,
subtract: AnimatedImplementation.subtract,
divide: AnimatedImplementation.divide,
multiply: AnimatedImplementation.multiply,
modulo: AnimatedImplementation.modulo,
diffClamp: AnimatedImplementation.diffClamp,
delay,
sequence,
parallel,
stagger,
loop,
event: AnimatedImplementation.event,
createAnimatedComponent,
attachNativeEvent,
forkEvent: AnimatedImplementation.forkEvent,
unforkEvent: AnimatedImplementation.unforkEvent,
Event: AnimatedEvent
};
export { AnimatedMock_default as default };
//# sourceMappingURL=AnimatedMock.mjs.map