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

This commit is contained in:
Naugtur 2012-01-15 00:34:51 +01:00
parent 401c554c80
commit 2ae803efb6
1 changed files with 25 additions and 0 deletions

View File

@ -174,6 +174,11 @@ var Reveal = (function(){
linkify(); linkify();
} }
//bind scrolling
if(window.addEventListener){
document.addEventListener('DOMMouseScroll', scrollStep, false);
}
// Read the initial hash // Read the initial hash
readURL(); 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 // Expose some methods publicly
return { return {
initialize: initialize, initialize: initialize,