| 554 | |
| 555 | let passiveSupported: boolean | null = null |
| 556 | export function passiveEventSupported() { |
| 557 | if (typeof passiveSupported === 'boolean') return passiveSupported |
| 558 | |
| 559 | let supported = false |
| 560 | try { |
| 561 | const options = { |
| 562 | get passive() { |
| 563 | supported = true |
| 564 | return false |
| 565 | }, |
| 566 | } |
| 567 | |
| 568 | const noop = () => {} |
| 569 | |
| 570 | window.addEventListener('test', noop, options) |
| 571 | window.removeEventListener('test', noop) |
| 572 | } catch (err) { |
| 573 | supported = false |
| 574 | } |
| 575 | passiveSupported = supported |
| 576 | return passiveSupported |
| 577 | } |
| 578 | |
| 579 | function isTouchStartEvent(e: unknown): e is TouchEvent { |
| 580 | return (e as TouchEvent).type === 'touchstart' |