Catch scrolling when drawer is open (fixes #1076) (Closes #1282)

master
Surma 2015-08-03 12:30:17 +01:00 committed by Addy Osmani
parent 4710fcb6db
commit 426395b3d2
1 changed files with 7 additions and 0 deletions

View File

@ -286,6 +286,10 @@ MaterialLayout.prototype.init = function() {
}
}
var eatEvent = function(ev) {
ev.preventDefault();
};
// Add drawer toggling button to our layout, if we have an openable drawer.
if (this.drawer_) {
var drawerButton = document.createElement('div');
@ -310,6 +314,8 @@ MaterialLayout.prototype.init = function() {
// not be present.
this.element_.classList.add(this.CssClasses_.HAS_DRAWER);
this.drawer_.addEventListener('mousewheel', eatEvent);
// If we have a fixed header, add the button to the header rather than
// the layout.
if (this.element_.classList.contains(this.CssClasses_.FIXED_HEADER)) {
@ -323,6 +329,7 @@ MaterialLayout.prototype.init = function() {
this.element_.appendChild(obfuscator);
obfuscator.addEventListener('click',
this.drawerToggleHandler_.bind(this));
obfuscator.addEventListener('mousewheel', eatEvent);
}
// Initialize tabs, if any.