#56 : Update pausable handlers
This commit is contained in:
@@ -18,8 +18,26 @@ export function createDispatcher(source) {
|
||||
|
||||
export function getIsTouchable() {
|
||||
return (
|
||||
('ontouchstart' in window) ||
|
||||
// ('ontouchstart' in window) || // not changing value during browser view switching (mobile <-> desktop)
|
||||
(navigator.maxTouchPoints > 0) ||
|
||||
(navigator.msMaxTouchPoints > 0)
|
||||
)
|
||||
}
|
||||
|
||||
export function addTouchableChangeEventListener(cb) {
|
||||
let isTouchable = getIsTouchable();
|
||||
cb(isTouchable)
|
||||
|
||||
function handleResize() {
|
||||
const isTouchableNext = getIsTouchable();
|
||||
if (isTouchable !== isTouchableNext) {
|
||||
cb(isTouchableNext)
|
||||
isTouchable = isTouchableNext
|
||||
}
|
||||
}
|
||||
|
||||
addResizeEventListener(handleResize)
|
||||
return () => {
|
||||
removeResizeEventListener(handleResize)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user