Skip to content

Commit

Permalink
fix(scrollView): on desktop, mousewheel only scrolls the right scroll…
Browse files Browse the repository at this point in the history
…View

Closes #1376
  • Loading branch information
ajoslin committed May 19, 2014
1 parent 4a21013 commit 3250d10
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion js/angular/directive/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function($timeout, $controller, $ionicBind) {
compile: function(element, attr) {
var innerElement;

element.addClass('scroll-content');
element.addClass('scroll-content ionic-scroll');

if (attr.scroll != 'false') {
//We cannot use normal transclude here because it breaks element.data()
Expand Down
2 changes: 1 addition & 1 deletion js/angular/directive/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function($timeout, $controller, $ionicBind) {
scope: true,
controller: function() {},
compile: function(element, attr) {
element.addClass('scroll-view');
element.addClass('scroll-view ionic-scroll');

//We cannot transclude here because it breaks element.data() inheritance on compile
var innerElement = jqLite('<div class="scroll"></div>');
Expand Down
11 changes: 0 additions & 11 deletions js/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,6 @@
return null;
},

elementHasParent: function(element, parent) {
var current = element;
while (current) {
if (current.parentNode === parent) {
return true;
}
current = current.parentNode;
}
return false;
},

/**
* @ngdoc method
* @name ionic.DomUtil#rectContains
Expand Down
5 changes: 4 additions & 1 deletion js/views/scrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -838,12 +838,15 @@ ionic.views.Scroll = ionic.views.View.inherit({
};

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

self.hintResize();
self.scrollBy(
e.wheelDeltaX/self.options.wheelDampen,
-e.wheelDeltaY/self.options.wheelDampen
);

self.__fadeScrollbars('in');
clearTimeout(self.__wheelHideBarTimeout);
self.__wheelHideBarTimeout = setTimeout(function() {
Expand Down

0 comments on commit 3250d10

Please sign in to comment.