(FusePerfectScrollbar) Unbind 'keydown' events of the PerfectScrollbar instances. This fixes the Angular Material inputs' high CPU usage.. The real problem is in the Angular Material library but we cannot do anything about it so we have removed the keyboard events of the PerfectScrollbar which resolves this years long issue.

This commit is contained in:
sercan 2018-10-12 23:59:03 +03:00
parent cbd1c3e21c
commit 4da339cef1

View File

@ -15,7 +15,7 @@ export class FusePerfectScrollbarDirective implements AfterViewInit, OnDestroy
{
isInitialized: boolean;
isMobile: boolean;
ps: PerfectScrollbar;
ps: PerfectScrollbar | any;
// Private
private _enabled: boolean | '';
@ -200,6 +200,19 @@ export class FusePerfectScrollbarDirective implements AfterViewInit, OnDestroy
this.ps = new PerfectScrollbar(this.elementRef.nativeElement, {
...this.fusePerfectScrollbarOptions
});
// Unbind 'keydown' events of PerfectScrollbar since it causes an extremely
// high CPU usage on Angular Material inputs.
// Loop through all the event elements of this PerfectScrollbar instance
this.ps.event.eventElements.forEach((eventElement) => {
// If we hit to the element with a 'keydown' event...
if ( typeof eventElement.handlers['keydown'] !== 'undefined' )
{
// Unbind it
eventElement.element.removeEventListener('keydown', eventElement.handlers['keydown'][0]);
}
});
}
/**