Giter VIP home page Giter VIP logo

react-bouncefix's Introduction

react-bouncefix

A ReactJS component which stops elastic bouncing from moving the entire page(body) when scrollable element has reached the extremes.

Credit

This is a ReactJS implementation of @jaridmargolin's bouncefix.js

Why?

IOS (since IOS 5) offers native touch scrolling within nested containers via -webkit-overflow-scrolling: touch;, however, if scrolling occurs at one of the extremes, top or bottom, the elastic bounce occurs on the page rather than the nested container. bouncefix.js offers a viable solution to fix this issue. react-bouncefix is a reuseable component for ReactJS based applications

note: If there is no content to scroll, scrolling is blocked on the container. This may cause issues if attempting to implement a scroll to refresh feature. This can be overcome creating a wrapper inside of your container and setting the height to 100% with a top and bottom padding of 1px (Not perfect, hackish, but it works)

##Install

npm install react-bouncefix

##Example For documentation on how to use react, check out http://facebook.github.io/react/docs/getting-started.html

####For projects using JSX

/** @jsx React.DOM */
var Bouncefix = require('react-bouncefix');

var MyComponent = React.createClass({
  render: function() {
    return (
    	<Bouncefix className="Bouncefix">
    		Hello from MyComponent!
    	</Bouncefix>
    );
  }
});


React.renderComponent(
	MyComponent,
	document.getElementById('container')
);

Add to your css

.Bouncefix {
	overflow-y: auto;
	overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

##Parameters

#####component By default this will be a div, however, you may specify any React supported element. See http://facebook.github.io/react/docs/tags-and-attributes.html#html-elements

<Bouncefix className="Bouncefix" componentClass="ul">
    Hello from MyComponent!
</Bouncefix>

react-bouncefix's People

Contributors

atridgedcosta avatar qwtel avatar github1 avatar lwansbrough avatar

Watchers

Brett Lamy avatar James Cloos 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.