<div id="wrapper"> <div id="scroller"> <ul> <li>...</li> </ul> </div> </div>
var myScroller = Modernizr.touch ? new iScroll('scroller') : null;
#wrapper { overflow: auto; } /* #wrapper - */ /* head.touch Modernizer' - */ .touch #wrapper { overflow: hidden; }
function getScroll(elem, iscroll) { var x, y; if (Modernizr.touch && iscroll) { x = iscroll.x * -1; y = iscroll.y * -1; } else { x = elem.scrollLeft; y = elem.scrollTop; } return {x: x, y: y}; }
var myScroller = Modernizr.touch ? new iScroll('scroller') : null; (function animationLoop(){ window.requestAnimationFrame(animationLoop); var scroll = getScroll(window, myScroller); // scroll.x; scroll.y; })();
Why for animation you should use requestAnimationFrame
Source: https://habr.com/ru/post/147351/
All Articles