Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 1x 6x 6x 6x 6x 6x | /** * Copyright (c) Siemens 2016 - 2025 * SPDX-License-Identifier: MIT */ // Adds a window listener which can optionally be active, returns the unregister function. // For some events (e.g. "touchmove") an explicit "passive: false" is required in order to // be able to do $event.preventDefault(). Unfortunately there is no way in Angular to pass // options to Rendrer2/EventManager event handling. export const listenGlobal = ( eventName: string, handler: (e: any) => void, active?: boolean ): (() => void) => { let opts: any = false; Iif (active !== undefined) { opts = { passive: !active }; } window.addEventListener(eventName, handler, opts); return () => { window.removeEventListener(eventName, handler, opts); }; }; |