Last active: 2 years ago
/**
* Swap page x and y when screen orientation is portrait.
* Method:
* pageX = pageY
* pageY = -pageX
* @param e
* @returns {[{pageY, pageX}]}
*/
getTouches(e) {
const isPortrait = window.matchMedia('(orientation: portrait)').matches;
const touches = [
{
pageX: e.touches[0].pageX,
pageY: e.touches[0].pageY,
},
];
if (isPortrait) {
[touches[0].pageX, touches[0].pageY] = [
touches[0].pageY,
-touches[0].pageX,
];
}
return touches;
},