From: Naugtur Date: Sat, 14 Jan 2012 23:34:51 +0000 (+0100) Subject: Added support for smart scrolling through slides. Scrolling events are throttled... X-Git-Tag: 1.2.0~19^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2ae803efb6659474c61e4dba885bf6a5abf814fe;p=reveal.js.git Added support for smart scrolling through slides. Scrolling events are throttled to prevent going too far --- diff --git a/js/reveal.js b/js/reveal.js index 75d3141..88d201a 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -173,6 +173,11 @@ var Reveal = (function(){ // Add some 3D magic to our anchors linkify(); } + + //bind scrolling + if(window.addEventListener){ + document.addEventListener('DOMMouseScroll', scrollStep, false); + } // Read the initial hash readURL(); @@ -676,6 +681,26 @@ var Reveal = (function(){ } } + var stepT=0; + function scrollStep(e){ + clearTimeout(stepT); + stepT=setTimeout(function(){ + if(e.detail>0){ + if(availableRoutes().down){ + navigateDown() + }else{ + navigateRight() + } + }else{ + if(availableRoutes().up){ + navigateUp() + }else{ + navigateLeft() + } + } + },200); + } + // Expose some methods publicly return { initialize: initialize,