UNPKG

react-native-reanimated

Version:

More powerful alternative to Animated library for React Native.

82 lines (67 loc) 2.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.updatePropsJestWrapper = exports.updateProps = exports.default = exports.colorProps = exports.ColorProperties = void 0; var _Colors = require("./Colors"); var _core = require("./core"); var _jsReanimated = require("./js-reanimated"); var _PlatformChecker = require("./PlatformChecker"); /* global _updatePropsPaper _updatePropsFabric */ // copied from react-native/Libraries/Components/View/ReactNativeStyleAttributes const colorProps = ['backgroundColor', 'borderBottomColor', 'borderColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'borderStartColor', 'borderEndColor', 'color', 'shadowColor', 'textDecorationColor', 'tintColor', 'textShadowColor', 'overlayColor']; exports.colorProps = colorProps; const ColorProperties = !(0, _core.isConfigured)() ? [] : (0, _core.makeShareable)(colorProps); exports.ColorProperties = ColorProperties; let updatePropsByPlatform; if ((0, _PlatformChecker.shouldBeUseWeb)()) { updatePropsByPlatform = (_, updates, maybeViewRef) => { 'worklet'; if (maybeViewRef) { maybeViewRef.items.forEach((item, _) => { (0, _jsReanimated._updatePropsJS)(updates, item); }); } }; } else { if (global._IS_FABRIC) { updatePropsByPlatform = (viewDescriptors, updates, _) => { 'worklet'; for (const key in updates) { if (ColorProperties.indexOf(key) !== -1) { updates[key] = (0, _Colors.processColor)(updates[key]); } } viewDescriptors.value.forEach(viewDescriptor => { _updatePropsFabric(viewDescriptor.shadowNodeWrapper, updates); }); }; } else { updatePropsByPlatform = (viewDescriptors, updates, _) => { 'worklet'; for (const key in updates) { if (ColorProperties.indexOf(key) !== -1) { updates[key] = (0, _Colors.processColor)(updates[key]); } } viewDescriptors.value.forEach(viewDescriptor => { _updatePropsPaper(viewDescriptor.tag, viewDescriptor.name || 'RCTView', updates); }); }; } } const updateProps = updatePropsByPlatform; exports.updateProps = updateProps; const updatePropsJestWrapper = (viewDescriptors, updates, maybeViewRef, animatedStyle, adapters) => { adapters.forEach(adapter => { adapter(updates); }); animatedStyle.current.value = { ...animatedStyle.current.value, ...updates }; updateProps(viewDescriptors, updates, maybeViewRef); }; exports.updatePropsJestWrapper = updatePropsJestWrapper; var _default = updateProps; exports.default = _default; //# sourceMappingURL=UpdateProps.js.map