create-expo-cljs-app
Version:
Create a react native application with Expo and Shadow-CLJS!
39 lines (35 loc) • 1.19 kB
JavaScript
import { createAnimatedSet as set } from '../core/AnimatedSet';
import interpolate from '../derived/interpolate';
import InternalAnimatedValue from './InternalAnimatedValue';
import { Platform } from 'react-native';
import { evaluateOnce } from '../derived/evaluateOnce';
import ReanimatedModule from '../../ReanimatedModule';
import { val } from '../val';
// Animated value wrapped with extra methods for omit cycle of dependencies
export default class AnimatedValue extends InternalAnimatedValue {
setValue(value) {
this.__detachAnimation(this._animation);
if (
Platform.OS === 'web' ||
Platform.OS === 'windows' ||
Platform.OS === 'macos'
) {
this._updateValue(val(value));
} else {
if (ReanimatedModule.setValue && typeof value === 'number') {
// FIXME Remove it after some time
// For OTA-safety
// FIXME handle setting value with a node
ReanimatedModule.setValue(this.__nodeID, value);
} else {
evaluateOnce(set(this, value), this);
}
}
}
toString() {
return `AnimatedValue, id: ${this.__nodeID}`;
}
interpolate(config) {
return interpolate(this, config);
}
}