// If true; each slide will be pushed to the browser history
history: true,
+ // Flags if mouse wheel navigation should be enabled
+ mouseWheel: true,
+
// Apply a 3D roll to links on hover
rollingLinks: true,
- CSS is now much more explicit, rooted at #reveal, to prevent conflicts
- Config option for disabling updates to URL, defaults to true
- Anchors with image children no longer rotate in 3D on hover
+- Support for mouse wheel navigation ([naugtur](https://github.com/naugtur))
#### 1.1
history: false,
transition: 'default',
theme: 'default',
+ mouseWheel: true,
rollingLinks: true
},
document.body.style['WebkitTransform'] !== undefined ||
document.body.style['MozTransform'] !== undefined ||
document.body.style['msTransform'] !== undefined ||
- document.body.style['OTransform'] !== undefined;
+ document.body.style['OTransform'] !== undefined,
+
+ // Throttles mouse wheel navigation
+ mouseWheelTimeout = 0;
/**
* Starts up the slideshow by applying configuration
dom.wrapper.classList.add( config.theme );
}
+ if( config.mouseWheel ) {
+ document.addEventListener('DOMMouseScroll', onDocumentMouseScroll, false); // FF
+ document.addEventListener('mousewheel', onDocumentMouseScroll, false);
+ }
+
if( config.rollingLinks ) {
// Add some 3D magic to our anchors
linkify();
}
-
- //bind scrolling
- if(window.addEventListener){
- document.addEventListener('DOMMouseScroll', scrollStep, false);
- }
// Read the initial hash
readURL();
slide();
}
}
+
+ /**
+ * Handles mouse wheel scrolling, throttled to avoid
+ * skipping multiple slides.
+ */
+ function onDocumentMouseScroll( event ){
+ clearTimeout( mouseWheelTimeout );
+
+ mouseWheelTimeout = setTimeout( function() {
+ var delta = event.detail || -event.wheelDelta;
+ if( delta > 0 ) {
+ availableRoutes().down ? navigateDown() : navigateRight();
+ }
+ else {
+ availableRoutes().up ? navigateUp() : navigateLeft();
+ }
+ }, 100 );
+ }
/**
* Handler for the window level 'hashchange' event.
}
}
- 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,