UNPKG

react-native-web-ui-components

Version:

[![Dependencies](https://img.shields.io/badge/dependencies-renovate-brightgreen.svg)](https://github.com/CareLuLu/react-native-web-ui-components/issues/12) [![Codacy Badge](https://img.shields.io/codacy/grade/c0ef990240a84ab7abee7af64602dd6d/master)](http

42 lines (38 loc) 916 B
import React from 'react'; import PropTypes from 'prop-types'; import RNDraggable from 'react-draggable'; import noop from 'lodash/noop'; const Draggable = ({ children, axis, disabled, handle, onDragStart, onDragEnd }) => { const onStart = (e, data) => onDragStart(data); const onStop = (e, data) => onDragEnd(data); return /*#__PURE__*/React.createElement(RNDraggable, { handle: handle ? `.${handle}` : undefined, disabled: disabled, onStart: onStart, onStop: onStop, axis: axis }, children({})); }; Draggable.propTypes = { children: PropTypes.func.isRequired, onDragStart: PropTypes.func, onDragEnd: PropTypes.func, axis: PropTypes.oneOf(['x', 'y', 'both']), disabled: PropTypes.bool, handle: PropTypes.string }; Draggable.defaultProps = { onDragStart: noop, onDragEnd: noop, axis: 'both', disabled: false, handle: null }; export default Draggable;