Skip to content

Commit

Permalink
Merge pull request #42 from thomasprost/bugfix-mousewheel
Browse files Browse the repository at this point in the history
bugfix on IE11 not getting mousewheel originalEvent
  • Loading branch information
lukesnowden authored Mar 14, 2017
2 parents dc4650a + e7164fe commit 46b3319
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions js/fsvs.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,23 @@

var mouseWheelHandler = function( ev ) {
var e = window.event || ev;
var wheely = 0;
if (e.type == 'mousewheel') {
wheely = (e.originalEvent.wheelDelta * -1);
}else if (e.type == 'DOMMouseScroll') {
wheely = 40 * e.originalEvent.detail;
}
var wheely = 0;
if (e.type == 'mousewheel') {
// Fix for IE11 originalEvent being undefined
// IE offers wheelDelta and detail directly through the event
if(e.originalEvent !== undefined) {
wheely = (e.originalEvent.wheelDelta * -1);
} else {
wheely = (e.wheelDelta * -1);
}
}
else if (e.type == 'DOMMouseScroll') {
if(e.originalEvent !== undefined) {
wheely = 40 * e.originalEvent.detail;
} else {
wheely = 40 * e.detail;
}
}
wheely = ( e.wheelDelta || -e.detail || wheely);
var delta = Math.max( -1, Math.min( 1, wheely ) );
if( isChrome() ) {
Expand Down

0 comments on commit 46b3319

Please sign in to comment.