1 | /**
|
2 | * Get touch coordinate (x or y) from touchpad input
|
3 | *
|
4 | * @param object e Event
|
5 | * @param string coordinate Coordinate ("x" or "y", case insensitive)
|
6 | */
|
7 | function getTouchCoordinate(e, coordinate) {
|
8 | const coordinateUc = coordinate.toUpperCase();
|
9 |
|
10 | return /touch/.test(e.type) ? (e.originalEvent || e).changedTouches[0][`page${coordinateUc}`] : e[`page${coordinateUc}`];
|
11 | }
|
12 |
|
13 | export default {
|
14 | getTouchCoordinate,
|
15 | };
|