Improve page scrolling performance part 1
Remove unnecessary scroll event listener for tooltip-enabled elements, which should only be set only when tooltip is shown. Given the number of such elements, this resulted if noticeable performance boost when removed. Bug: Issue 8825 Change-Id: Id627d727702bb9ea29efdd99906909b59f42cbde
This commit is contained in:
@@ -51,7 +51,6 @@
|
||||
|
||||
detached() {
|
||||
this._handleHideTooltip();
|
||||
this.unlisten(window, 'scroll', '_handleWindowScroll');
|
||||
},
|
||||
|
||||
_setupTooltipListeners() {
|
||||
@@ -59,9 +58,6 @@
|
||||
this._hasSetupTooltipListeners = true;
|
||||
|
||||
this.addEventListener('mouseenter', this._handleShowTooltip.bind(this));
|
||||
this.addEventListener('mouseleave', this._handleHideTooltip.bind(this));
|
||||
this.addEventListener('tap', this._handleHideTooltip.bind(this));
|
||||
this.listen(window, 'scroll', '_handleWindowScroll');
|
||||
},
|
||||
|
||||
_handleShowTooltip(e) {
|
||||
@@ -91,6 +87,9 @@
|
||||
tooltip.style.visibility = null;
|
||||
|
||||
this._tooltip = tooltip;
|
||||
this.listen(window, 'scroll', '_handleWindowScroll');
|
||||
this.listen(this, 'mouseleave', '_handleHideTooltip');
|
||||
this.listen(this, 'tap', '_handleHideTooltip');
|
||||
},
|
||||
|
||||
_handleHideTooltip(e) {
|
||||
@@ -100,6 +99,9 @@
|
||||
return;
|
||||
}
|
||||
|
||||
this.unlisten(window, 'scroll', '_handleWindowScroll');
|
||||
this.unlisten(this, 'mouseleave', '_handleHideTooltip');
|
||||
this.unlisten(this, 'tap', '_handleHideTooltip');
|
||||
this.setAttribute('title', this._titleText);
|
||||
if (this._tooltip && this._tooltip.parentNode) {
|
||||
this._tooltip.parentNode.removeChild(this._tooltip);
|
||||
|
Reference in New Issue
Block a user