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

Commit 088d2e6

Browse files
crisbetokara
authored andcommitted
fix(panel): don't bind scroll event if scrolling is disabled (#9947)
1 parent e80d0d2 commit 088d2e6

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/components/panel/panel.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,23 +1889,24 @@ MdPanelRef.prototype._configureClickOutsideToClose = function() {
18891889
* @private
18901890
*/
18911891
MdPanelRef.prototype._configureScrollListener = function() {
1892-
var updatePosition = angular.bind(this, this._updatePosition);
1893-
var debouncedUpdatePosition = this._$$rAF.throttle(updatePosition);
1894-
var self = this;
1892+
// No need to bind the event if scrolling is disabled.
1893+
if (!this.config['disableParentScroll']) {
1894+
var updatePosition = angular.bind(this, this._updatePosition);
1895+
var debouncedUpdatePosition = this._$$rAF.throttle(updatePosition);
1896+
var self = this;
18951897

1896-
var onScroll = function() {
1897-
if (!self.config['disableParentScroll']) {
1898+
var onScroll = function() {
18981899
debouncedUpdatePosition();
1899-
}
1900-
};
1900+
};
19011901

1902-
// Add listeners.
1903-
this._$window.addEventListener('scroll', onScroll, true);
1902+
// Add listeners.
1903+
this._$window.addEventListener('scroll', onScroll, true);
19041904

1905-
// Queue remove listeners function.
1906-
this._removeListeners.push(function() {
1907-
self._$window.removeEventListener('scroll', onScroll, true);
1908-
});
1905+
// Queue remove listeners function.
1906+
this._removeListeners.push(function() {
1907+
self._$window.removeEventListener('scroll', onScroll, true);
1908+
});
1909+
}
19091910
};
19101911

19111912

0 commit comments

Comments
 (0)