GithubHelp home page GithubHelp logo

scrollpolyfill.js's Introduction

scrollPolyfill.js

Experimental scroll polyfil for touch devides.

Enables:

The problem and the solution

  1. Touch does not fire during scroll on mobile/touch enabled devices.
  2. Touch devices pause scripting after fast flick move until animation finishes.

Scripts trigger missing scroll events by attaching to native touchstart, touchmove and touchend events enabling basic paralax effects even on touch devices.

The Lite version of the script actually does no scrolling at all, just monitors areas for scrolling change. Than it triggers scroll event when the scroll change occurs. Paralax will work while slow scrolling the page, but will stop during the momentum scrolling and will continue to work only after the animation finishes. This behaviour might cause jumpy paralax experience.

If you need to support parallax during the momentum scrolling, try the full version of the script which halts native scroll and tries to emulate it back.

How to use

This is a drop-in, no installation script. Just include the script before the </body> closing tag.

<script src="/path/to/scrollPolyfill.js" type="text/javascript"></script>

Known issues

  1. Only vertical scrolling is supported
  2. Default Android Browsers have some graphic-acceleration issues. Use the light version or wrap initialisation in user agent check and maybe fallback to lite version.
  3. Two finger scrolling causes jumps

Examples

Room for improvements

Some ideas that might be explored in future:

  1. RequestAnimationFrame() RAF fires just like the native solution only after the scrill has finished.
  2. Web workers

Enjoy!

@martin_adamko

scrollpolyfill.js's People

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.