source: trip-planner-front/node_modules/@angular/cdk/esm2015/a11y/fake-event-detection.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8/** Gets whether an event could be a faked `mousedown` event dispatched by a screen reader. */
9export function isFakeMousedownFromScreenReader(event) {
10 // Some screen readers will dispatch a fake `mousedown` event when pressing enter or space on
11 // a clickable element. We can distinguish these events when both `offsetX` and `offsetY` are
12 // zero. Note that there's an edge case where the user could click the 0x0 spot of the screen
13 // themselves, but that is unlikely to contain interaction elements. Historially we used to check
14 // `event.buttons === 0`, however that no longer works on recent versions of NVDA.
15 return event.offsetX === 0 && event.offsetY === 0;
16}
17/** Gets whether an event could be a faked `touchstart` event dispatched by a screen reader. */
18export function isFakeTouchstartFromScreenReader(event) {
19 const touch = (event.touches && event.touches[0]) ||
20 (event.changedTouches && event.changedTouches[0]);
21 // A fake `touchstart` can be distinguished from a real one by looking at the `identifier`
22 // which is typically >= 0 on a real device versus -1 from a screen reader. Just to be safe,
23 // we can also look at `radiusX` and `radiusY`. This behavior was observed against a Windows 10
24 // device with a touch screen running NVDA v2020.4 and Firefox 85 or Chrome 88.
25 return !!touch && touch.identifier === -1 && (touch.radiusX == null || touch.radiusX === 1) &&
26 (touch.radiusY == null || touch.radiusY === 1);
27}
28//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFrZS1ldmVudC1kZXRlY3Rpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL2ExMXkvZmFrZS1ldmVudC1kZXRlY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRU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09IDEpICYmXG4gICAgICAgICAodG91Y2gucmFkaXVzWSA9PSBudWxsIHx8IHRvdWNoLnJhZGl1c1kgPT09IDEpO1xufVxuIl19
Note: See TracBrowser for help on using the repository browser.