UNPKG

react-native-reanimated

Version:

More powerful alternative to Animated library for React Native.

39 lines (37 loc) 1.79 kB
'use strict'; import { getCompoundComponentName, getPropsBuilder } from '../../../common'; import { filterCSSAndStyleProperties } from '../../utils'; import { setViewStyle } from '../proxy'; import CSSAnimationsManager from './CSSAnimationsManager'; import CSSTransitionsManager from './CSSTransitionsManager'; export default class CSSManager { constructor({ shadowNodeWrapper, viewTag, reactViewName = 'RCTView' }, componentDisplayName = '') { const tag = this.viewTag = viewTag; const wrapper = shadowNodeWrapper; const compoundComponentName = getCompoundComponentName(reactViewName, componentDisplayName); this.propsBuilder = getPropsBuilder(compoundComponentName); this.cssAnimationsManager = new CSSAnimationsManager(wrapper, tag, compoundComponentName); this.cssTransitionsManager = new CSSTransitionsManager(wrapper, tag); } update(style) { const [animationProperties, transitionProperties, filteredStyle] = filterCSSAndStyleProperties(style); const hasAnimationOrTransition = animationProperties !== null || transitionProperties !== null; const normalizedStyle = hasAnimationOrTransition ? this.propsBuilder.build(filteredStyle) : undefined; // We need to update view style only for animations (e.g. when a property is // specified only in a subset of keyframes and start/end value comes from style). if (normalizedStyle && animationProperties) { setViewStyle(this.viewTag, normalizedStyle); } this.cssTransitionsManager.update(transitionProperties, normalizedStyle ?? {}); this.cssAnimationsManager.update(animationProperties); } unmountCleanup() { this.cssAnimationsManager.unmountCleanup(); this.cssTransitionsManager.unmountCleanup(); } } //# sourceMappingURL=CSSManager.js.map