1.0.15 • Published 5 years ago

@codebet/react-native-draggable v1.0.15

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

react-native-draggable

Draggable item for react-native!

How to use

return (
    <View >
        <Draggable renderSize={56} renderColor='black' offsetX={-100} offsetY={-200} pressDrag={()=>alert('touched!!')} tolerance={5} />
            <ChildCompoent />
        <Draggable/>
    </View>
);

Demo

N|Solid in my project =>

return (
    <View style={{backgroundColor: 'blue', flex: 0.5}} >
        <Draggable renderShape='image' imageSource={this.state.source} renderSize={80}
            offsetX={0} offsetY={0}
            pressDragRelease={this._changeFace}
            longPressDrag={()=>console.log('long press')}
            pressDrag={()=>console.log('press drag')}
            pressInDrag={()=>console.log('in press')}
            pressOutDrag={()=>console.log('out press')}
        />
    </View>
);

Event Demo

DEMO2

Props spec & Example

Properties

PropTypeExampleDefaultDescription
tolerancenumber{25}{0}Distance component can move and also trigger click
offsetXnumber{0}{100}offsetX with center
offsetYnumber{100}{100}offsetY with center
xnumber{0}---position x
ynumber{0}---position y
znumber{0}---position z
reversebool{true}{true}reverse flag

Events

EventTypeDescription
pressDragfunconPress event
pressDragReleasefuncrelease drag event
longPressDragfunclong press event
pressInDragfuncin press event
pressOutDragfuncout press event

Methods

MethodparamsDescription
reversePosition---manually reset Draggable to start position

What's next?

This Draggable is used to be a Draggable Button in my project. Let me know if you have any idea or demand, let's discuss and develop it.