Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 7f249f9

Browse files
Splaktarjelbourn
authored andcommitted
fix(tabs): use standard wheel event instead of non-standard mousewheel (#11686)
handle horizontal scrolling as well - there are other scroll devices besides mouse wheels fix minor Closure type issue with animateScrollTo() Fixes #11654
1 parent 459c03c commit 7f249f9

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/components/tabs/js/tabScroll.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function MdTabScroll ($parse) {
77
compile: function ($element, attr) {
88
var fn = $parse(attr.mdTabScroll, null, true);
99
return function ngEventHandler (scope, element) {
10-
element.on('mousewheel', function (event) {
10+
element.on('wheel', function (event) {
1111
scope.$apply(function () { fn(scope, { $event: event }); });
1212
});
1313
};

src/components/tabs/js/tabsController.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,16 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
348348

349349
/**
350350
* When pagination is on, this makes sure the selected index is in view.
351-
* @param event
351+
* @param {WheelEvent} event
352352
*/
353353
function scroll (event) {
354354
if (!ctrl.shouldPaginate) return;
355355
event.preventDefault();
356-
ctrl.offsetLeft = fixOffset(ctrl.offsetLeft - event.wheelDelta);
356+
if (event.deltaY) {
357+
ctrl.offsetLeft = fixOffset(ctrl.offsetLeft + event.deltaY);
358+
} else if (event.deltaX) {
359+
ctrl.offsetLeft = fixOffset(ctrl.offsetLeft + event.deltaX);
360+
}
357361
}
358362

359363
/**
@@ -907,8 +911,8 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
907911

908912
/**
909913
* Takes an offset value and makes sure that it is within the min/max allowed values.
910-
* @param value
911-
* @returns {*}
914+
* @param {number} value
915+
* @returns {number}
912916
*/
913917
function fixOffset (value) {
914918
var elements = getElements();

src/core/util/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ function UtilFactory($document, $timeout, $compile, $rootScope, $$mdAnimate, $in
810810
/**
811811
* Animate the requested element's scrollTop to the requested scrollPosition with basic easing.
812812
*
813-
* @param {!HTMLElement} element The element to scroll.
813+
* @param {!Element} element The element to scroll.
814814
* @param {number} scrollEnd The new/final scroll position.
815815
* @param {number=} duration Duration of the scroll. Default is 1000ms.
816816
*/

0 commit comments

Comments
 (0)