UNPKG

ovenplayer

Version:

OvenPlayer is Open-Source HTML5 Player. OvenPlayer supports WebRTC Signaling from OvenMediaEngine for Sub-Second Latency Streaming.

23 lines (20 loc) 576 B
/** * Detect if a touch event happened on the left, middle, or right side of the element * @param {MouseEvent} event * @returns {'left'|'middle'|'right'} */ export default function getTouchSection(event) { /** * @type {DOMRect} */ const clientRect = event.target.getBoundingClientRect(); // is it on the right if (event.offsetX >= ((2/3)*clientRect.width)) { return 'right'; } // is it on the middle if (event.offsetX >= ((1/3)*clientRect.width)) { return 'middle'; } return 'left'; }