Giter Site home page Giter Site logo

kinetic-scroll's Introduction

Kinetic Scroll

This project provides a kinetic scroll for webkit-based browser that mimics iOS one. Key difference from all similar projects out there lies in the fact that this one uses canvas to render scroll itself. Canvas approach has to advantages:

  1. there's no need to include any scroll styles or images;
  2. it allows more precise rendering of the scroll in hi-dpi mode.

Basic usage

Assuming that you have following structure of the the scrollable element:

<div id="wrapper">
  <div id="content">
  …
  </div>
</div>

You just need to pass a wrapper node to kinetic scroll constructor:

new KineticScroll(document.getElementById('wrapper'));

It's necessary to have inner element encapsulating all the content (#content in this case) because this is what actually moves when you scroll the page.

Configuration

Options hash can be passed as optional second argument to the constructor containing any of the following properties:

  • vertical — (default true) allow vertical scroll.
  • verticalBar — (default true) show vertical scroll bar when scrolling.
  • horizontal — (default false) allow horizontal scroll.
  • horizontalBar — (default false) show horizontal scroll bar when scrolling.
  • ignoredSelector — (default "input, textarea, select") determines touching which elements doesn't trigger scroll.
  • paginated — (default false) enables paginated scroll; direction is determined based on previous options.
  • onPageCountChange — (default null) callback for page count change when in paginated mode. It's also called right after constructing scroll allowing you to build page indicator if necessary.
  • onCurrentPageChange — (default null) callback for current page change. Only used in paginated mode.

To see the demo download or clone this repo and open index.html in a Webkit-based browser (like Google Chrome or Safari).

License

Copyright (c) 2012 Dmitriy Kubyshkin

Dual licensed under the MIT and GPL licenses: http://www.opensource.org/licenses/mit-license.php http://www.gnu.org/licenses/gpl.html

kinetic-scroll's People

Watchers

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