From aab060ffcebae479954355bf02804882935ef8d2 Mon Sep 17 00:00:00 2001 From: Artur Androsovych Date: Wed, 20 Apr 2022 17:06:15 +0300 Subject: [PATCH] perf(module:anchor): mark `scroll` listener as passive (#7330) --- components/anchor/anchor.component.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/anchor/anchor.component.ts b/components/anchor/anchor.component.ts index abb202a88d..295e7f42a9 100644 --- a/components/anchor/anchor.component.ts +++ b/components/anchor/anchor.component.ts @@ -3,7 +3,7 @@ * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ -import { Platform } from '@angular/cdk/platform'; +import { normalizePassiveListenerOptions, Platform } from '@angular/cdk/platform'; import { DOCUMENT } from '@angular/common'; import { AfterViewInit, @@ -42,6 +42,8 @@ interface Section { const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'anchor'; const sharpMatcherRegx = /#([^#]+)$/; +const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: true }); + @Component({ selector: 'nz-anchor', exportAs: 'nzAnchor', @@ -143,7 +145,7 @@ export class NzAnchorComponent implements OnDestroy, AfterViewInit, OnChanges { } this.destroy$.next(); this.zone.runOutsideAngular(() => { - fromEvent(this.getContainer(), 'scroll') + fromEvent(this.getContainer(), 'scroll', passiveEventListenerOptions) .pipe(throttleTime(50), takeUntil(this.destroy$)) .subscribe(() => this.handleScroll()); });