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

fix(panel): don't bind scroll event if scrolling is disabled #9947

Merged
merged 1 commit into from
Nov 15, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/components/panel/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1889,23 +1889,24 @@ MdPanelRef.prototype._configureClickOutsideToClose = function() {
* @private
*/
MdPanelRef.prototype._configureScrollListener = function() {
var updatePosition = angular.bind(this, this._updatePosition);
var debouncedUpdatePosition = this._$$rAF.throttle(updatePosition);
var self = this;
// No need to bind the event if scrolling is disabled.
if (!this.config['disableParentScroll']) {
var updatePosition = angular.bind(this, this._updatePosition);
var debouncedUpdatePosition = this._$$rAF.throttle(updatePosition);
var self = this;

var onScroll = function() {
if (!self.config['disableParentScroll']) {
var onScroll = function() {
debouncedUpdatePosition();
}
};
};

// Add listeners.
this._$window.addEventListener('scroll', onScroll, true);
// Add listeners.
this._$window.addEventListener('scroll', onScroll, true);

// Queue remove listeners function.
this._removeListeners.push(function() {
self._$window.removeEventListener('scroll', onScroll, true);
});
// Queue remove listeners function.
this._removeListeners.push(function() {
self._$window.removeEventListener('scroll', onScroll, true);
});
}
};


Expand Down