Skip to content

Commit

Permalink
perf(module:back-top): mark scroll listener as passive (#7329)
Browse files Browse the repository at this point in the history
  • Loading branch information
arturovt committed Apr 20, 2022
1 parent aab060f commit 7f3c4e1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions components/back-top/back-top.component.ts
Expand Up @@ -4,7 +4,7 @@
*/

import { Direction, Directionality } from '@angular/cdk/bidi';
import { Platform } from '@angular/cdk/platform';
import { normalizePassiveListenerOptions, Platform } from '@angular/cdk/platform';
import { DOCUMENT } from '@angular/common';
import {
ChangeDetectionStrategy,
Expand Down Expand Up @@ -36,6 +36,8 @@ import { InputNumber } from 'ng-zorro-antd/core/util';

const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'backTop';

const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: true });

@Component({
selector: 'nz-back-top',
exportAs: 'nzBackTop',
Expand Down Expand Up @@ -138,7 +140,7 @@ export class NzBackTopComponent implements OnInit, OnDestroy, OnChanges {
this.scrollListenerDestroy$.next();
this.handleScroll();
this.zone.runOutsideAngular(() => {
fromEvent(this.getTarget(), 'scroll')
fromEvent(this.getTarget(), 'scroll', <AddEventListenerOptions>passiveEventListenerOptions)
.pipe(debounceTime(50), takeUntil(this.scrollListenerDestroy$))
.subscribe(() => this.handleScroll());
});
Expand Down

0 comments on commit 7f3c4e1

Please sign in to comment.