Giter VIP home page Giter VIP logo

react-native-draggable's Introduction

react-native-draggable

Build Status npm version

NPM

Draggable item for react-native!

npm install react-native-draggable --save
import Draggable from 'react-native-draggable';

How to use

return (
    <View >
        <Draggable renderSize={56} renderColor='black' offsetX={-100} offsetY={-200} renderText='A' pressDrag={()=>alert('touched!!')}/> 
        <Draggable reverse={false} renderColor='red' renderShape='square' offsetX={0} offsetY={0} renderText='B'/>
        <Draggable/>
	<Draggable x={50} y={50}>
		<YourComponent/>
	</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

Prop Type Example Default Description
renderText string 'ANY' '+' text of draggable
renderShape string 'circle' , 'square' , 'image' 'circle' shape type
imageSource source require('./img/xxx.png') --- image source
renderSize number {36} {36} draggable size
offsetX number {0} {100} offsetX with center
offsetY number {100} {100} offsetY with center
x number {0} --- position x
y number {0} --- position y
z number {0} --- position z
renderColor string 'black' 'yellowgreen' Colors
reverse bool {true} {true} reverse flag

Events

Event Type Description
pressDrag func onPress event
pressDragRelease func release drag event
longPressDrag func long press event
pressInDrag func in press event
pressOutDrag func out press event

Methods

Method params Description
reversePosition --- manually reset Draggable to start position
getPosition --- get the value of x, y, offsetX, offsetY

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.    

react-native-draggable's People

Contributors

btk avatar chuhangyu avatar mlix8hoblc avatar tongyy avatar venkatb4u avatar vigilantee avatar willbattel avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.