Parcourir la source

Added support for smart scrolling through slides. Scrolling events are throttled to prevent going too far

Naugtur il y a 12 ans
Parent
commit
2ae803efb6
1 fichiers modifiés avec 25 ajouts et 0 suppressions
  1. 25 0
      js/reveal.js

+ 25 - 0
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,