GithubHelp home page GithubHelp logo

fingerfoodstudios / react-native-directed-scrollview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chrisfisher/react-native-directed-scrollview

1.0 8.0 2.0 7.44 MB

A natively implemented scrollview component which lets you specify different scroll directions for child content.

License: MIT License

Java 51.84% JavaScript 19.59% Python 3.13% Objective-C 24.06% Ruby 1.37%

react-native-directed-scrollview's Introduction

react-native-directed-scrollview

demo

A natively implemented scrollview component which lets you specify different scroll directions for child content.

The iOS implementation extends the default UIScrollView component, whereas the Android implementation is custom and aims to provide some limited parity with the iOS api.

The following props are supported:

Prop Default Description
scrollEnabled true When false, the view cannot be scrolled via touch interaction.
pinchGestureEnabled true When true, ScrollView allows use of pinch gestures to zoom in and out.
minimumZoomScale 1.0 How far the content can zoom out.
maximumZoomScale 1.0 How far the content can zoom in.
bounces true Whether content bounces at the limits when scrolling.
bouncesZoom true Whether content bounces at the limits when zooming.
alwaysBounceHorizontal false When bounces is enabled, content will bounce horizontally even if the content is smaller than the bounds of the scroll view.
alwaysBounceVertical false When bounces is enabled, content will bounce vertically even if the content is smaller than the bounds of the scroll view..
ios showsVerticalScrollIndicator true Whether vertical scroll bars are visible.
ios showsHorizontalScrollIndicator true Whether horizontal scroll bars are visible.

The following methods are supported:

Method Example Description
scrollTo scrollTo({x: 100, y: 100, animated: true}) Scrolls to a given x and y offset.

Installation

  • npm install react-native-directed-scrollview --save
  • react-native link (or rnpm link)

Usage

To work properly this component requires that a fixed-size content container be specified through the contentContainerStyle prop.

import ScrollView, { ScrollViewChild } from 'react-native-directed-scrollview';
...

export default class Example extends Component {
  render() {
    return (
      <ScrollView
        bounces={true}
        bouncesZoom={true}
        maximumZoomScale={2.0}
        minimumZoomScale={0.5}
        showsHorizontalScrollIndicator={false}
        showsVerticalScrollIndicator={false}
        contentContainerStyle={styles.contentContainer}
        style={styles.container}
      >
        <ScrollViewChild scrollDirection={'both'}>
          // multi-directional scrolling content here...
        </ScrollViewChild>
        <ScrollViewChild scrollDirection={'vertical'}>
          // vertically scrolling content here...
        </ScrollViewChild>
        <ScrollViewChild scrollDirection={'horizontal'}>
          // horizontally scrolling content here...
        </ScrollViewChild>
      </ScrollView>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  contentContainer: {
    height: 1000,
    width: 1000,
  },
})

See the example project for more detail.

react-native-directed-scrollview's People

Contributors

aidurber avatar chrisfisher avatar dwrightffs avatar kevinsperrine avatar lecler-i avatar michaeldanieltom avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.