|
6 | 6 | * found in the LICENSE file at https://angular.io/license
|
7 | 7 | */
|
8 | 8 | import {ElementRef, NgZone} from '@angular/core';
|
9 |
| -import {Platform, supportsPassiveEventListeners} from '@angular/cdk/platform'; |
| 9 | +import {Platform, normalizePassiveListenerOptions} from '@angular/cdk/platform'; |
10 | 10 | import {isFakeMousedownFromScreenReader} from '@angular/cdk/a11y';
|
11 | 11 | import {RippleRef, RippleState} from './ripple-ref';
|
12 | 12 |
|
@@ -57,6 +57,9 @@ export const defaultRippleAnimationConfig = {
|
57 | 57 | */
|
58 | 58 | const ignoreMouseEventsTimeout = 800;
|
59 | 59 |
|
| 60 | +/** Options that apply to all the event listeners that are bound by the ripple renderer. */ |
| 61 | +const passiveEventOptions = normalizePassiveListenerOptions({passive: true}); |
| 62 | + |
60 | 63 | /**
|
61 | 64 | * Helper service that performs DOM manipulations. Not intended to be used outside this module.
|
62 | 65 | * The constructor takes a reference to the ripple directive's host element and a map of DOM
|
@@ -86,9 +89,6 @@ export class RippleRenderer {
|
86 | 89 | /** Time in milliseconds when the last touchstart event happened. */
|
87 | 90 | private _lastTouchStartEvent: number;
|
88 | 91 |
|
89 |
| - /** Options that apply to all the event listeners that are bound by the renderer. */ |
90 |
| - private _eventOptions = supportsPassiveEventListeners() ? ({passive: true} as any) : false; |
91 |
| - |
92 | 92 | /**
|
93 | 93 | * Cached dimensions of the ripple container. Set when the first
|
94 | 94 | * ripple is shown and cleared once no more ripples are visible.
|
@@ -235,8 +235,9 @@ export class RippleRenderer {
|
235 | 235 | this._removeTriggerEvents();
|
236 | 236 |
|
237 | 237 | this._ngZone.runOutsideAngular(() => {
|
238 |
| - this._triggerEvents.forEach((fn, type) => |
239 |
| - element.addEventListener(type, fn, this._eventOptions)); |
| 238 | + this._triggerEvents.forEach((fn, type) => { |
| 239 | + element.addEventListener(type, fn, passiveEventOptions); |
| 240 | + }); |
240 | 241 | });
|
241 | 242 |
|
242 | 243 | this._triggerElement = element;
|
@@ -305,7 +306,7 @@ export class RippleRenderer {
|
305 | 306 | _removeTriggerEvents() {
|
306 | 307 | if (this._triggerElement) {
|
307 | 308 | this._triggerEvents.forEach((fn, type) => {
|
308 |
| - this._triggerElement!.removeEventListener(type, fn, this._eventOptions); |
| 309 | + this._triggerElement!.removeEventListener(type, fn, passiveEventOptions); |
309 | 310 | });
|
310 | 311 | }
|
311 | 312 | }
|
|
0 commit comments