Skip to content

Commit

Permalink
fix(scroll): fix IE mousewheel scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Feb 13, 2015
2 parents 300528e + 25e173a commit be09433
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions js/views/scrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,24 @@ ionic.views.Scroll = ionic.views.View.inherit({
}
};

self.mouseWheel = ionic.animationFrameThrottle(function(e) {
var scrollParent = ionic.DomUtil.getParentOrSelfWithClass(e.target, 'ionic-scroll');
if (!self.options.freeze && scrollParent === self.__container) {

self.hintResize();
self.scrollBy(
(e.wheelDeltaX || e.deltaX || 0) / self.options.wheelDampen,
(-e.wheelDeltaY || e.deltaY || 0) / self.options.wheelDampen
);

self.__fadeScrollbars('in');
clearTimeout(self.__wheelHideBarTimeout);
self.__wheelHideBarTimeout = setTimeout(function() {
self.__fadeScrollbars('out');
}, 100);
}
});

if ('ontouchstart' in window) {
// Touch Events
container.addEventListener("touchstart", self.touchStart, false);
Expand All @@ -826,6 +844,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
document.addEventListener("pointermove", self.touchMove, false);
document.addEventListener("pointerup", self.touchEnd, false);
document.addEventListener("pointercancel", self.touchEnd, false);
document.addEventListener("wheel", self.mouseWheel, false);

} else if (window.navigator.msPointerEnabled) {
// IE10, WP8 (Pointer Events)
Expand All @@ -834,6 +853,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
document.addEventListener("MSPointerMove", self.touchMove, false);
document.addEventListener("MSPointerUp", self.touchEnd, false);
document.addEventListener("MSPointerCancel", self.touchEnd, false);
document.addEventListener("wheel", self.mouseWheel, false);

} else {
// Mouse Events
Expand Down Expand Up @@ -877,24 +897,6 @@ ionic.views.Scroll = ionic.views.View.inherit({
mousedown = false;
};

self.mouseWheel = ionic.animationFrameThrottle(function(e) {
var scrollParent = ionic.DomUtil.getParentOrSelfWithClass(e.target, 'ionic-scroll');
if (!self.options.freeze && scrollParent === self.__container) {

self.hintResize();
self.scrollBy(
(e.wheelDeltaX || e.deltaX || 0) / self.options.wheelDampen,
(-e.wheelDeltaY || e.deltaY || 0) / self.options.wheelDampen
);

self.__fadeScrollbars('in');
clearTimeout(self.__wheelHideBarTimeout);
self.__wheelHideBarTimeout = setTimeout(function() {
self.__fadeScrollbars('out');
}, 100);
}
});

container.addEventListener("mousedown", self.mouseDown, false);
if(self.options.preventDefault) container.addEventListener("mousemove", self.mouseMoveBubble, false);
document.addEventListener("mousemove", self.mouseMove, false);
Expand Down

0 comments on commit be09433

Please sign in to comment.