GithubHelp home page GithubHelp logo

wix-incubator / react-native-swipe-view Goto Github PK

View Code? Open in Web Editor NEW
124.0 312.0 23.0 131 KB

Native container for a React Native view which supports swipe behavior (for swipe to delete and such)

License: MIT License

Python 5.23% Java 41.64% JavaScript 15.70% Objective-C 37.44%

react-native-swipe-view's Introduction

react-native-swipe-view

A native container which provides a smooth drag interaction with any react-native view to implement a horizontal swiping behaviour, for example: swiping a "card" view out of the screen to delete it.

Installation

Install from npm:

npm i --save react-native-swipe-view

Now link the native libraries:

Android

Add to the app build.gradle dependencies:

compile project(':RNSwipeView')

Add to settings.gradle:

include ':RNSwipeView'
project(':RNSwipeView').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-swipe-view/android')

Add the package to your MainApplication.java getPackages list:

import com.wix.RNSwipeView.SwipeViewPackage;

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      //add this pacakge:
      new SwipeViewPackage()
  );
}
};

iOS

In Xcode, drag the SwipeView.xcodeproj from your node modules to the libraries list in the Project Navigator. Then add libSwipeView to your app target "Linked Frameworks and Libraries"

Usage

react-native-swipe-view export a Component called SwipeView which you can use to wrap any hirarchy of child views that you wish to be contained and interacted with a swipe behavior.

For example:

//import the swipe view container
import {SwipeView} from 'react-native-swipe-view';

//use it in your render function
<SwipeView changeOpacity removeViewOnSwipedOut style={{borderWidth: 4}}>
	<Text style={styles.welcome}>
		This is a swipe view!
	</Text>
	<Text style={styles.instructions}>
		Drag it to interact
	</Text>
</SwipeView>

supported props

prop default type description
changeOpacity false Boolean Should the component change content alphw while dragging
removeViewOnSwipedOut false Boolean Should the component be removed from the hierarchy after it is swiped out
minPanToComplete 0.5 Number The distance from the view center which needs to be completed in percents for the "swipe out" action to happen. If the threshold is not reached it will bounce back
bounceBackAnimDuration 0.35 Number Duration of bounce back animation when the threshold defined in minPanToComplete is not matched
bounceBackAnimDamping 0.65 Number Damping param of iOS bounce back animation when the threshold defined in minPanToComplete is not matched
onSwipeStart - Function Callback function which is called when the swiping action starts. A direction param is provided wiht left or right value
onWillBeSwipedOut - Function Callback function which is called right before a view is swiped out (when it passed the minPanToComplete threshold). A direction param is provided wiht left or right value
onSwipedOut - Function Callback function which is called after the "swiped out" animation is done. A direction param is provided wiht left or right value
onWillBounceBack - Function Callback function which is called right before a view bounces back (when it fails to pass the minPanToComplete threshold). A direction param is provided wiht left or right value
onBouncedBack - Function Callback function which is called after the "bounce back" animation is done. A direction param is provided wiht left or right value

react-native-swipe-view's People

Contributors

artald avatar danielzlotin avatar guyca avatar rotemmiz avatar yedidyak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-swipe-view's Issues

Not working

The example shown is not working. Swiping is not triggered neither the styling applied. I am using it along with react-native-navigation. Everything compiles fine though! Using Java sdk1.8, and android sdk 25.0.1 on Windows 10.

Get direction from the onSwipedOut event

<SwipeView changeOpacity removeViewOnSwipedOut onSwipedOut={(direction) => { if (direction === 'right') { // Do something } else if (direction === 'left') { // Do something } }} >

But the RCTDirectEventBlock isn't being called with the direction, so that we cannot use the direction property in the JS.

I saw in the Objective C that the code looks like:
_onSwipedOut(@{@"direction": directionString}); self.onSwipedOut = nil;
But even direction.direction (in the upper code) doesn't work.

android events

Hi,
events on android are not passing the direction value. I can't neither find it on the java code. So i guess, the code still on WIP? any comments?

deprecated API.

E:\forbuild\node_modules\react-native-swipe-view\android\src\main\java\com\wix\RNSwipeView\SwipeViewPackage.java:22: error: method does not override or implement a method from a supertype
@OverRide
^
Note: E:\forbuild\node_modules\react-native-swipe-view\android\src\main\java\com\wix\RNSwipeView\SwipeView.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
:RNSwipeView:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':RNSwipeView:compileReleaseJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

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.