ScrollLogic
This project is based on zynga/scroller which was not maintained any longer. This repo does not have much in common with the original though. It's a radically stripped down and optimized version which serves only one purpose.
It's a pure logic component for one-axis decelerated scrolling, imitating the way mobile devices do native scrolling. No render loop, no zooming, no snapping, no paging. It only serves a single purpose: providing the most accurate and high-performance backbone for your scrolling needs. It does not seem very useful on it's own, but I needed exactly that for [enter project name as soon as it's public ;)]. Since scroll-logic does not contain any rendering loop, it does not do anything unless you request something from it (see getOffset
below).
Usage
npm install scroll-logic
for usage with browserify or use the window.ScrollLogic
global.
var ScrollLogic = require('scroll-logic');
var scrollLogic = new ScrollLogic({
bouncing: false,
containerLength: 800,
contentLength: 23000
});
scrollLogic.setContainerLength(containerLength);
scrollLogic.setContentLength(contentLength);
var offset = scrollLogic.getOffset();
scrollLogic.setOffset(newOffset);
scrollLogic.beginInteraction(offset, timestamp);
scrollLogic.interact(offset, timestamp);
scrollLogic.endInteraction(offset, timestamp);