|
|
@ -1,4 +1,5 @@ |
|
|
|
import Countries, { Country, PhoneCodesMain } from "../countries"; |
|
|
|
import Countries, { Country, PhoneCodesMain } from "../countries"; |
|
|
|
|
|
|
|
import { cancelEvent } from "../helpers/dom"; |
|
|
|
import mediaSizes from "../helpers/mediaSizes"; |
|
|
|
import mediaSizes from "../helpers/mediaSizes"; |
|
|
|
import { clamp } from "../helpers/number"; |
|
|
|
import { clamp } from "../helpers/number"; |
|
|
|
import { isTouchSupported } from "../helpers/touchSupport"; |
|
|
|
import { isTouchSupported } from "../helpers/touchSupport"; |
|
|
@ -116,24 +117,15 @@ let onMouseMove = (e: MouseEvent) => { |
|
|
|
//console.log('mousemove', diffX, diffY);
|
|
|
|
//console.log('mousemove', diffX, diffY);
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let onClick = (e: MouseEvent | TouchEvent) => { |
|
|
|
const onClick = (e: MouseEvent | TouchEvent) => { |
|
|
|
/* if(touchSupport && e.type == 'touchstart') { |
|
|
|
|
|
|
|
const target = findUpClassName(e.target, 'btn-menu'); |
|
|
|
|
|
|
|
if(!target) { |
|
|
|
|
|
|
|
window.addEventListener('touchend', (e) => { |
|
|
|
|
|
|
|
return cancelEvent(e); |
|
|
|
|
|
|
|
}, {once: true}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} *//* else if(!touchSupport && e.type == 'mousedown') {
|
|
|
|
|
|
|
|
const target = findUpClassName(e.target, 'btn-menu'); |
|
|
|
|
|
|
|
if(!target) { |
|
|
|
|
|
|
|
closeBtnMenu(); |
|
|
|
closeBtnMenu(); |
|
|
|
return cancelEvent(e); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
} */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//e.preventDefault();
|
|
|
|
const onKeyDown = (e: KeyboardEvent) => { |
|
|
|
|
|
|
|
if(e.key == 'Escape') { |
|
|
|
closeBtnMenu(); |
|
|
|
closeBtnMenu(); |
|
|
|
|
|
|
|
cancelEvent(e); |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export const closeBtnMenu = () => { |
|
|
|
export const closeBtnMenu = () => { |
|
|
@ -149,17 +141,13 @@ export const closeBtnMenu = () => { |
|
|
|
openedMenuOnClose = null; |
|
|
|
openedMenuOnClose = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//document.body.classList.remove('disable-hover');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isTouchSupported) { |
|
|
|
if(isTouchSupported) { |
|
|
|
window.removeEventListener('touchmove', onClick); |
|
|
|
window.removeEventListener('touchmove', onClick); |
|
|
|
//window.removeEventListener('touchstart', onClick);
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
window.removeEventListener('mousemove', onMouseMove); |
|
|
|
window.removeEventListener('mousemove', onMouseMove); |
|
|
|
//window.removeEventListener('mousedown', onClick);
|
|
|
|
|
|
|
|
//window.removeEventListener('click', onClick);
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.removeEventListener('keydown', onKeyDown, {capture: true}); |
|
|
|
window.removeEventListener('click', onClick); |
|
|
|
window.removeEventListener('click', onClick); |
|
|
|
window.removeEventListener('contextmenu', onClick); |
|
|
|
window.removeEventListener('contextmenu', onClick); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -194,13 +182,11 @@ export function openBtnMenu(menuElement: HTMLElement, onClose?: () => void) { |
|
|
|
|
|
|
|
|
|
|
|
if(isTouchSupported) { |
|
|
|
if(isTouchSupported) { |
|
|
|
window.addEventListener('touchmove', onClick, {once: true}); |
|
|
|
window.addEventListener('touchmove', onClick, {once: true}); |
|
|
|
//window.addEventListener('touchstart', onClick);
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
window.addEventListener('mousemove', onMouseMove); |
|
|
|
window.addEventListener('mousemove', onMouseMove); |
|
|
|
//window.addEventListener('mousedown', onClick);
|
|
|
|
|
|
|
|
//window.addEventListener('click', onClick, {once: true});
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('keydown', onKeyDown, {capture: true}); |
|
|
|
window.addEventListener('click', onClick, {once: true}); |
|
|
|
window.addEventListener('click', onClick, {once: true}); |
|
|
|
window.addEventListener('contextmenu', onClick, {once: true}); |
|
|
|
window.addEventListener('contextmenu', onClick, {once: true}); |
|
|
|
} |
|
|
|
} |
|
|
|