davidaurelio / TouchScroll

TouchScroll is a JavaScript- and CSS 3-based scroller for devices using Webkit Mobile. It is meant to mimic “native” scrolling feeling and behavior as much as possible.
http://uxebu.com/blog/2010/04/27/touchscroll-a-scrolling-layer-for-webkit-mobile/
BSD 2-Clause "Simplified" License
474 stars 61 forks source link

TouchScroll

TouchScroll is a JavaScript/CSS 3-based scrolling layer for Webkit Mobile, espeacially iPhone, Android, and iPad. It allows to configure scrolling behaviour in many ways and to use fixed interface elements.

Dependencies

TouchScroll depends on css-beziers, a library for computations on cubic bezier curves.

Usage

To use TouchScroll you need an element with fixed height. Have a look at the demo for an elegant solution using display: -webkit-box.

The stylesheet is mandatory at the moment. It will be made optional in the future for cases when scrollbars aren’t needed.

<link rel="stylesheet" src="https://github.com/davidaurelio/TouchScroll/raw/master/touchscroll.css">
<!-- … -->
<div id="scroller">
    <!-- contents go here -->
</div>
<script src="https://github.com/davidaurelio/TouchScroll/raw/master/css-beziers.js"></script>
<script src="https://github.com/davidaurelio/TouchScroll/raw/master/touchscroll.js"></script>
<script>
    var scroller = new TouchScroll(document.querySelector("#scroller"));
</script>

To enable the elasticity/bouncing effect, add {elastic: true} as second parameter to the instantiation:

<script>
    var scroller = new TouchScroll(document.querySelector("#scroller"), {elastic: true});
</script>

Set the scroller to overflow: auto to enable scrolling in other environments.

The scroller automatically adapts its size to content changes and window resizes/orientation changes.

Limitations/Known Issues

To Do

Contact

E-Mail: da AT uxebu.com Twitter: @void_0