UNPKG

react-native-sortables

Version:

Powerful Sortable Components for Flexible Content Reordering in React Native

33 lines (31 loc) 1.02 kB
"use strict"; import React from "react"; import Animated from 'react-native-reanimated'; import { IS_WEB } from '../../constants'; import { componentWithRef } from '../../utils/react'; /** * We have to use a custom view if we want to properly handle view layout * measurements on web. * (onLayout is called with 0 dimensions for views which have display: none, * so it gets called on navigation between screens) */ import { jsx as _jsx } from "react/jsx-runtime"; const AnimatedOnLayoutView = componentWithRef(function AnimatedOnLayoutView({ onLayout, ...rest }, ref) { return /*#__PURE__*/_jsx(Animated.View, { ...rest, ref: ref, onLayout: e => { const el = e.nativeEvent.target; // We want to call onLayout only for displayed views to prevent // layout updates on navigation between screens if (el?.offsetParent) { onLayout?.(e); } } }); }); export default IS_WEB ? AnimatedOnLayoutView : Animated.View; //# sourceMappingURL=AnimatedOnLayoutView.js.map