Added support for smart scrolling through slides. Scrolling events are throttled...
authorNaugtur <naugtur@gmail.com>
Sat, 14 Jan 2012 23:34:51 +0000 (00:34 +0100)
committerNaugtur <naugtur@gmail.com>
Sat, 14 Jan 2012 23:34:51 +0000 (00:34 +0100)
js/reveal.js

index 75d31415f2db9ee6b6f37e44b1c527d06ac5f524..88d201a3dfb58a54629f12f4e034ee4a08726407 100644 (file)
@@ -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,