React Native Touch Through View

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.

Installation:

# NPM
$ npm install react-native-touch-through-view --save

Usage:

import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  Image,
  Dimensions,
  ScrollView,
  ListView,
  Button,
  View
} from 'react-native';
import { TouchThroughView, TouchThroughWrapper } from 'react-native-touch-through-view';

const ReactNativeTouchThroughViewExample = () => (
  <View style={styles.container}>
    <View style={styles.artistInfo}>
      <View style={styles.albumImageWrapper}>
        <Image source={require("./album.jpg")} style={styles.albumImage} />
      </View>
      <Button style={styles.button} title="Play" onPress={() => { }} />
    </View>
    <TouchThroughWrapper style={styles.scrollWrapper}>
      <ListView
        style={styles.scroller}
        dataSource={dataSource}
        renderHeader={() => <TouchThroughView style={styles.touchThroughView} />}
        renderRow={(rowData) => {
          return (
            <Text style={styles.itemRow}>{rowData}</Text>
          )
        }}>
      </ListView>
    </TouchThroughWrapper>
  </View>
);

export default ReactNativeTouchThroughViewExample

const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
const rows = [];

let i = 0;
while (i < 1000) {
  rows.push(`Item ${i}`);
  i++;
}

const dataSource = ds.cloneWithRows(rows);

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#eee',
    paddingTop: 20,
  },
  button: {
    marginTop: 20,
  },
  albumImage: {
    width: 300,
    height: 300,
  },
  albumImageWrapper: {
    marginTop: 20,
    marginBottom: 10,
    padding: 10,
    width: 320,
    height: 320,
    alignSelf: 'center',
    backgroundColor: 'white',
    shadowColor: '#ccc',
    shadowOpacity: 1,
    shadowRadius: 5,
    shadowOffset: { width: 0, height: 0 },
  },
  artistInfo: {
    position: 'absolute',
    top: 20,
    left: 0,
    right: 0,
    height: 400,
    zIndex: 0,
  },
  scroller: {
    zIndex: 1,
  },
  scrollWrapper: {
    flex: 1,
  },
  touchThroughView: {
    height: 400,
    flex: 1,
  },
  itemRow: {
    backgroundColor: '#ddd',
    padding: 20,
    borderBottomWidth: 5,
    borderBottomColor: '#000',
  }
});

Preview:

React Native Touch Through View

Download Details:

Author: rome2rio

Live Demo: View The Demo

Download Link: Download The Source Code

Official Website: https://github.com/rome2rio/react-native-touch-through-view

License: MIT

You Might Be Interested In:

Add Comment