UNPKG

react-native-reanimated

Version:

More powerful alternative to Animated library for React Native.

47 lines (40 loc) 1.39 kB
import JSReanimated from './JSReanimated'; const reanimatedJS = new JSReanimated(); global._makeShareableClone = c => c; global._scheduleOnJS = setImmediate; export const _updatePropsJS = (updates, viewRef) => { if (viewRef._component) { const component = viewRef._component; const [rawStyles] = Object.keys(updates).reduce((acc, key) => { const value = updates[key]; const index = typeof value === 'function' ? 1 : 0; acc[index][key] = value; return acc; }, [{}, {}]); if (typeof component.setNativeProps === 'function') { setNativeProps(component, rawStyles); } else if (Object.keys(component.props).length > 0) { Object.keys(component.props).forEach(key => { if (!rawStyles[key]) { return; } const dashedKey = key.replace(/[A-Z]/g, m => '-' + m.toLowerCase()); component._touchableNode.setAttribute(dashedKey, rawStyles[key]); }); } else { console.warn('It is not possible to manipulate component'); } } }; const setNativeProps = (component, style) => { const previousStyle = component.previousStyle ? component.previousStyle : {}; const currentStyle = { ...previousStyle, ...style }; component.previousStyle = currentStyle; component.setNativeProps({ style: currentStyle }); }; export default reanimatedJS; //# sourceMappingURL=index.js.map