UNPKG

@jsmlt/jsmlt

Version:

JavaScript Machine Learning

20 lines (17 loc) 570 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTouchCoordinate = getTouchCoordinate; /* eslint import/prefer-default-export: "off" */ /** * Get touch coordinate (x or y) from touchpad input. * * @param {object} e - Event * @param {string} coordinate - Coordinate ("x" or "y", case insensitive) */ function getTouchCoordinate(e, coordinate) { var coordinateUc = coordinate.toUpperCase(); return (/touch/.test(e.type) ? (e.originalEvent || e).changedTouches[0]["page" + coordinateUc] : e["page" + coordinateUc] ); }