Skip to content

Commit aab060f

Browse files
authored
perf(module:anchor): mark scroll listener as passive (#7330)
1 parent ffef342 commit aab060f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

components/anchor/anchor.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
44
*/
55

6-
import { Platform } from '@angular/cdk/platform';
6+
import { normalizePassiveListenerOptions, Platform } from '@angular/cdk/platform';
77
import { DOCUMENT } from '@angular/common';
88
import {
99
AfterViewInit,
@@ -42,6 +42,8 @@ interface Section {
4242
const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'anchor';
4343
const sharpMatcherRegx = /#([^#]+)$/;
4444

45+
const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: true });
46+
4547
@Component({
4648
selector: 'nz-anchor',
4749
exportAs: 'nzAnchor',
@@ -143,7 +145,7 @@ export class NzAnchorComponent implements OnDestroy, AfterViewInit, OnChanges {
143145
}
144146
this.destroy$.next();
145147
this.zone.runOutsideAngular(() => {
146-
fromEvent(this.getContainer(), 'scroll')
148+
fromEvent(this.getContainer(), 'scroll', <AddEventListenerOptions>passiveEventListenerOptions)
147149
.pipe(throttleTime(50), takeUntil(this.destroy$))
148150
.subscribe(() => this.handleScroll());
149151
});

0 commit comments

Comments
 (0)