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

Commit

Permalink
fix(autocomplete): disable scroll events for autocomplete wrap layer
Browse files Browse the repository at this point in the history
At the moment we set the z-index of the `autocomplete-wrap` to `51`, that's why it is usable while an open scrollmask
So we only need to disable the scroll events to prevent scrolling when hovering over the `autocomplete-wrap`

Fixes #6585. Fixes #5230. Fixes #5890. Closes #6589.
  • Loading branch information
devversion authored and ThomasBurleson committed Apr 19, 2016
1 parent 4b29ddf commit 8c79f32
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/components/autocomplete/js/autocompleteController.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $mdTheming,
selectedItemWatchers = [],
hasFocus = false,
lastCount = 0,
fetchesInProgress = 0;
fetchesInProgress = 0,
enableWrapScroll = null;

//-- public variables with handlers
defineProperty('hidden', handleHiddenChange, true);
Expand Down Expand Up @@ -247,15 +248,39 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $mdTheming,
if (elements) {
$mdUtil.nextTick(function () {
$mdUtil.disableScrollAround(elements.ul);
enableWrapScroll = disableElementScrollEvents(angular.element(elements.wrap));
}, false, $scope);
}
} else if (hidden && !oldHidden) {
$mdUtil.nextTick(function () {
$mdUtil.enableScrolling();

if (enableWrapScroll) {
enableWrapScroll();
enableWrapScroll = null;
}
}, false, $scope);
}
}

/**
* Disables scrolling for a specific element
*/
function disableElementScrollEvents(element) {

function preventDefault(e) {
e.preventDefault();
}

element.on('wheel', preventDefault);
element.on('touchmove', preventDefault);

return function() {
element.off('wheel', preventDefault);
element.off('touchmove', preventDefault);
}
}

/**
* When the user mouses over the dropdown menu, ignore blur events.
*/
Expand Down

0 comments on commit 8c79f32

Please sign in to comment.