GithubHelp home page GithubHelp logo

apollo880 / react-native-touch-through-view Goto Github PK

View Code? Open in Web Editor NEW

This project forked from simonhoss/react-native-touch-through-view

0.0 0.0 0.0 2.21 MB

Component library that allows for scroll views and table views to scroll over interactable content without poor performing size and bounds animations.

JavaScript 75.06% Ruby 0.79% Objective-C 9.36% Java 14.79%

react-native-touch-through-view's Introduction

react-native-touch-through-view npm version

React Native Touch Through View is a simple component library that allows for scroll views and table views to scroll over interactable content without poor performing size and bounds animations.

You can achieve Spotify or Apple maps style drawer effects with the full performance of UIScrollView and without laggy onScroll events.

Spotify style Maps style

Built to solve issues like http://stackoverflow.com/questions/39995024/propagate-touch-events-through-scrollview

Installation

Simply use react-native link react-native-touch-through-view to add the library to your project.

How to use it

  1. Import the library import { TouchThroughView, TouchThroughWrapper } from 'react-native-touch-through-view';
  2. Wrap your ListView or ScrollView in the <TouchThroughWrapper> element.
  3. Add <TouchThroughView /> elements wherever you want the users touch to be passed through to the view behind. You can style these views just like any other view and put them anywhere in the view you want.

eg.

// Markup for listview with a touch through header.
<TouchThroughWrapper style={styles.scrollWrapper}>
      <ListView
        style={styles.scroller}
        dataSource={dataSource}
        renderHeader={() => <TouchThroughView style={styles.touchThroughView} />}
        renderRow={(rowData) => {
          return (
              <View style={styles.itemRow}>
                <Text>{rowData}</Text>
              </View>
          )
        }}>
      </ListView>
    </TouchThroughWrapper>

Have a look at the demo in the example directory if you need more help.

Android Installation

For Android you have to do the normal react-native link. Also you have to change MainActivity inside you project. See example below

package com.reactnativetouchthroughviewexample;

import com.facebook.react.ReactActivity;
import android.view.MotionEvent;
import com.rome2rio.android.reactnativetouchthroughview.TouchThroughTouchHandlerInterface; 
import com.rome2rio.android.reactnativetouchthroughview.TouchThroughTouchHandler; 

public class MainActivity extends ReactActivity implements TouchThroughTouchHandlerInterface { 

    private TouchThroughTouchHandler touchThroughTouchHandler = new TouchThroughTouchHandler();

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "reactnativetouchthroughviewexample";
    }

    public TouchThroughTouchHandler getTouchThroughTouchHandler() {
        return touchThroughTouchHandler;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        touchThroughTouchHandler.handleTouchEvent(ev);

        return super.dispatchTouchEvent(ev);
    }
}

Credits

Brought to you by the team at Rome2rio. Find out how to join our team at https://www.rome2rio.com/careers/

react-native-touch-through-view's People

Contributors

simonhoss avatar tankers746 avatar monsieurbon avatar adapptor-jez avatar interactivejunky avatar richardlindhout avatar traviswimer avatar bondehagen avatar brianop avatar 1e1f avatar milesizzo 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.