Skip to content

Commit 7f3c4e1

Browse files
authored
perf(module:back-top): mark scroll listener as passive (#7329)
1 parent aab060f commit 7f3c4e1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

components/back-top/back-top.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import { Direction, Directionality } from '@angular/cdk/bidi';
7-
import { Platform } from '@angular/cdk/platform';
7+
import { normalizePassiveListenerOptions, Platform } from '@angular/cdk/platform';
88
import { DOCUMENT } from '@angular/common';
99
import {
1010
ChangeDetectionStrategy,
@@ -36,6 +36,8 @@ import { InputNumber } from 'ng-zorro-antd/core/util';
3636

3737
const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'backTop';
3838

39+
const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: true });
40+
3941
@Component({
4042
selector: 'nz-back-top',
4143
exportAs: 'nzBackTop',
@@ -138,7 +140,7 @@ export class NzBackTopComponent implements OnInit, OnDestroy, OnChanges {
138140
this.scrollListenerDestroy$.next();
139141
this.handleScroll();
140142
this.zone.runOutsideAngular(() => {
141-
fromEvent(this.getTarget(), 'scroll')
143+
fromEvent(this.getTarget(), 'scroll', <AddEventListenerOptions>passiveEventListenerOptions)
142144
.pipe(debounceTime(50), takeUntil(this.scrollListenerDestroy$))
143145
.subscribe(() => this.handleScroll());
144146
});

0 commit comments

Comments
 (0)