UNPKG

react-native-reanimated

Version:

More powerful alternative to Animated library for React Native.

61 lines (48 loc) 1.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = exports._updatePropsJS = void 0; var _JSReanimated = _interopRequireDefault(require("./JSReanimated")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const reanimatedJS = new _JSReanimated.default(); global._makeShareableClone = c => c; global._scheduleOnJS = setImmediate; 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'); } } }; exports._updatePropsJS = _updatePropsJS; const setNativeProps = (component, style) => { const previousStyle = component.previousStyle ? component.previousStyle : {}; const currentStyle = { ...previousStyle, ...style }; component.previousStyle = currentStyle; component.setNativeProps({ style: currentStyle }); }; var _default = reanimatedJS; exports.default = _default; //# sourceMappingURL=index.js.map