/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ /** Gets whether an event could be a faked `mousedown` event dispatched by a screen reader. */ export function isFakeMousedownFromScreenReader(event) { // Some screen readers will dispatch a fake `mousedown` event when pressing enter or space on // a clickable element. We can distinguish these events when `event.buttons` is zero, or // `event.detail` is zero depending on the browser: // - `event.buttons` works on Firefox, but fails on Chrome. // - `detail` works on Chrome, but fails on Firefox. return event.buttons === 0 || event.detail === 0; } /** Gets whether an event could be a faked `touchstart` event dispatched by a screen reader. */ export function isFakeTouchstartFromScreenReader(event) { const touch = (event.touches && event.touches[0]) || (event.changedTouches && event.changedTouches[0]); // A fake `touchstart` can be distinguished from a real one by looking at the `identifier` // which is typically >= 0 on a real device versus -1 from a screen reader. Just to be safe, // we can also look at `radiusX` and `radiusY`. This behavior was observed against a Windows 10 // device with a touch screen running NVDA v2020.4 and Firefox 85 or Chrome 88. return (!!touch && touch.identifier === -1 && (touch.radiusX == null || touch.radiusX === 1) && (touch.radiusY == null || touch.radiusY === 1)); } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFrZS1ldmVudC1kZXRlY3Rpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL2ExMXkvZmFrZS1ldmVudC1kZXRlY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsOEZBQThGO0FBQzlGLE1BQU0sVUFBVSwrQkFBK0IsQ0FBQyxLQUFpQjtJQUMvRCw2RkFBNkY7SUFDN0Ysd0ZBQXdGO0lBQ3hGLG1EQUFtRDtJQUNuRCwyREFBMkQ7SUFDM0Qsb0RBQW9EO0lBQ3BELE9BQU8sS0FBSyxDQUFDLE9BQU8sS0FBSyxDQUFDLElBQUksS0FBSyxDQUFDLE1BQU0sS0FBSy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