1.2.1 • Published 7 months ago

@shamilkotta/rn-drag-resize v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

@shamilkotta/rn-drag-resize

Draggable and Resizable component using React Native Reanimated

This library is a fork of reanimated-drag-resize.

  • Event start and end callbacks
  • 4 corner resizing

Drag resize

Getting started

Install the library:

yarn add @shamilkotta/rn-drag-resize

Required peer dependencies

dependencyrequired version
react-native-reanimated>= 2.0.0
react-native-gesture-handler>= *

Usage

import DragResizable from '@shamilkotta/rn-drag-resize';

Example

import DragResizable from '@shamilkotta/rn-drag-resize';

...
const [bounds, setBounds] = useState({ width: 0, height: 0 });

...
  <SafeAreaView style={styles.container}>
    <View
      onLayout={(ev) => {
        const layout = ev.nativeEvent.layout;
        setBounds({ width: layout.width, height: layout.height });
      }}
      style={styles.container}
    >
      <DragResizable
        heightBound={bounds.height}
        widthBound={bounds.width}
        left={10}
        top={10}
      >
        <View style={styles.box} />
      </DragResizable>
    </View>
  </SafeAreaView>
...

Props

Options

nametypedescriptiondefault
isDraggablebooleanCan be used to enable or disable the dragtrue
isResizablebooleanCan be used to enable or disable the resizetrue
topnumberTop position of the box-
leftnumberLeft position of the box-
minWidthnumberMinimum width limit for resize50
minHeightnumberMinimum height limit for resize50
heightBoundnumberY axis boundary for drag-
widthBoundnumberX axis boundary for drag-
heightnumberHeight of the box50
widthnumberWidth of the box150
scalenumberResize or drag factor1
resizeHandlersArrayVisible resize handlers['bottomLeft', 'bottomRight', 'topLeft', 'topRight']
renderHandlerReactNodeHandler component-
styleViewStyleBox style-

Callbacks

namedescriptionparamsexpected return
onDragStartWill be called when the drag starts-void
onDragEndWill be called at the end of dragBoxDimensionvoid
onResizeStartWill be called when the resize starts-void
onResizeEndWill be called at the end of dragBoxDimensionvoid
onTapWill be called, when user taps on the box-void

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

1.2.1

7 months ago

1.2.0

7 months ago

1.1.4

7 months ago

1.1.3

7 months ago

1.1.2

7 months ago

1.1.1

7 months ago