UNPKG

react-native-swipe-list

Version:

<!--[![Build Status][build-badge]][build]--> [![Version][version-badge]][package] ![Supports iOS and Android][support-badge] [![MIT License][license-badge]][license]

36 lines (35 loc) 1.55 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = __importStar(require("react")); const react_native_1 = require("react-native"); const Swipeable_1 = __importDefault(require("react-native-gesture-handler/Swipeable")); exports.SwipeableRow = ({ info, renderLeftActions, renderRightActions, children, closeOnScroll, isScrolling, }) => { const rowRef = react_1.useRef(); const close = () => { if (!rowRef.current) { return; } rowRef.current.close(); }; react_1.useEffect(() => { if (isScrolling && closeOnScroll) { close(); } }, [closeOnScroll, isScrolling]); return (react_1.default.createElement(Swipeable_1.default, { renderLeftActions: () => { return renderLeftActions && renderLeftActions(info); }, renderRightActions: () => { return renderRightActions && renderRightActions(info); }, leftThreshold: 40, rightThreshold: 40, friction: 2, ref: ref => (rowRef.current = ref) }, react_1.default.createElement(react_native_1.View, null, children))); };