Installations
npm install react-native-draggable
Developer
tongyy
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
8.16.1
NPM Version
6.4.1
Statistics
314 Stars
128 Commits
89 Forks
8 Watching
32 Branches
7 Contributors
Updated on 07 Nov 2024
Languages
JavaScript (51.42%)
TypeScript (20.92%)
Ruby (11.88%)
Objective-C (7.62%)
Java (6.59%)
Starlark (1.34%)
C (0.23%)
Total Downloads
Cumulative downloads
Total Downloads
1,102,148
Last day
-3.1%
1,016
Compared to previous day
Last week
4.3%
5,992
Compared to previous week
Last month
5.6%
26,202
Compared to previous month
Last year
-5.1%
281,463
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
16
react-native-draggable
UPDATE DEC 2019 (v3.0.0) - This repo has just been completely refreshed and contains very different functionality, please see the new props and usage below
Draggable item for react-native!
npm install react-native-draggable
import Draggable from 'react-native-draggable';
How to use
return (
<View >
<Draggable x={75} y={100} renderSize={56} renderColor='black' renderText='A' isCircle shouldReverse onShortPressRelease={()=>alert('touched!!')}/>
<Draggable x={200} y={300} renderColor='red' renderText='B'/>
<Draggable/>
<Draggable x={50} y={50}>
<YourComponent/>
</Draggable>
</View>
);
return (
<View style={{backgroundColor: 'blue', flex: 1}} >
<Draggable
imageSource={require('./trump1.png')}
renderSize={80}
x={200}
y={300}
onDragRelease={this._changeFace}
onLongPress={()=>console.log('long press')}
onShortPressRelease={()=>console.log('press drag')}
onPressIn={()=>console.log('in press')}
onPressOut={()=>console.log('out press')}
/>
</View>
);
Props spec & Example
Properties
Prop | Type | Example | Default | Description |
---|---|---|---|---|
renderText | string | 'ANY' | '+' | text of draggable |
isCircle | bool | {true} | --- | render as circle |
renderSize | number | {36} | {36} | draggable size |
imageSource | source | require('./img/xxx.png') | --- | image source |
renderColor | string | 'black' | --- | Colors |
children | Component | <Text>Sup</Text> | --- | children to render as draggable |
shouldReverse | bool | {false} | {false} | should draggable spring back to start when released |
disabled | bool | {false} | {false} | should draggable be disabled |
debug | bool | {false} | {false} | should show a debug visualization |
touchableOpacityProps | Object | { activeOpactiy: .1 } | --- | props passed to TouchableOpacity component |
animatedViewProps | Object | { accessibilityHint: 'drag' } | --- | props passed to Animated.View component |
x | number | {0} | 0 | initial position x |
y | number | {0} | 0 | initial position y |
z | number | {1} | 1 | z-index / elevation |
minX | number | {0} | --- | min X value for left edge of component |
minY | number | {0} | --- | min Y value for top edge of component |
maxX | number | {0} | --- | max X value for right edge of component |
maxY | number | {0} | --- | max Y value for bottom edge of component |
Events
Event | Type | Arguments | Description |
---|---|---|---|
onDrag | func | event, gestureState | called every frame component is moved |
onShortPressRelease | func | event | called when a press is released that isn't a long press or drag |
onDragRelease | func | event, gestureState, bounds | called when a drag is released |
onLongPress | func | event | called when a long press is started |
onPressIn | func | event | called when a press is started |
onPressOut | func | event | called when a press is stopped, or the component is dragged |
onRelease | func | event, wasDragging | called at the end of interaction, regardless if press or drag |
 onReverse |  func |  |  called when a drag is released, if shouldReverse is true |
Arguments (event, gestureState)
event
Argument | Description |
---|---|
changedTouches | Array of all touch events that have changed since the last event |
identifier | The ID of the touch |
locationX | The X position of the touch, relative to the element |
locationY | The Y position of the touch, relative to the element |
pageX | The X position of the touch, relative to the root element |
pageY | The Y position of the touch, relative to the root element |
target | The node id of the element receiving the touch event |
timestamp | A time identifier for the touch, useful for velocity calculation |
touches | Array of all current touches on the screen |
gestureState
Argument | Description |
---|---|
stateID | ID of the gestureState- persisted as long as there at least one touch on screen |
moveX | the latest screen coordinates of the recently-moved touch |
moveY | the latest screen coordinates of the recently-moved touch |
x0 | the screen coordinates of the responder grant |
y0 | the screen coordinates of the responder grant |
dx | accumulated distance of the gesture since the touch started |
dy | accumulated distance of the gesture since the touch started |
vx | current velocity of the gesture |
vy | current velocity of the gesture |
numberActiveTouches | Number of touches currently on screen |
gestureState | called at the end of interaction, regardless if press or drag |
bounds
Argument | Description |
---|---|
left | as x at the top left corner |
top | as y at the top left corner |
right | as x at the bottom right corner |
bottom | as y at the bottom right corner |
Methods (not supported above V2.0.0)
Method | Params | Description |
---|---|---|
reversePosition | --- | use onReverse callback instead. manually reset Draggable to start position |
getPosition | --- | use onDragRelease callback instead. get the accurate coordinates x,y from the bounds |
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.
No vulnerabilities found.
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
binaries present in source code
Details
- Warn: binary detected: example/DraggableDemo/android/gradle/wrapper/gradle-wrapper.jar:1
Reason
Found 3/7 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 28 are checked with a SAST tool
Reason
60 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-f5x2-xv93-4p23
- Warn: Project is vulnerable to: GHSA-gmpm-xp43-f7g6
- Warn: Project is vulnerable to: GHSA-pf27-929j-9pmm
- Warn: Project is vulnerable to: GHSA-327c-qx3v-h673
- Warn: Project is vulnerable to: GHSA-x4cf-6jr3-3qvp
- Warn: Project is vulnerable to: GHSA-mph8-6787-r8hw
- Warn: Project is vulnerable to: GHSA-7mhc-prgv-r3q4
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-v8v8-6859-qxm4
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-w7rc-rwvf-8q5r
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-4cpg-3vgw-4877
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-rxrc-rgv4-jpvx
- Warn: Project is vulnerable to: GHSA-7f53-fmmv-mfjv
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-gff7-g5r8-mg8m
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-662x-fhqg-9p8v
- Warn: Project is vulnerable to: GHSA-394c-5j6w-4xmx
- Warn: Project is vulnerable to: GHSA-78cj-fxph-m83p
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-h6q6-9hqw-rwfv
- Warn: Project is vulnerable to: GHSA-5fg8-2547-mr8q
- Warn: Project is vulnerable to: GHSA-crh6-fp67-6883
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
2.1
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More