Last active
March 12, 2021 07:38
-
-
Save kntmr/d34a086fc87fb89105428b7e64f38144 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<style> | |
.lock { | |
overflow: hidden; | |
} | |
.overlay { | |
z-index: 98; | |
position: fixed; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
background-color: rgba(0,0,0,0.75); | |
} | |
</style> | |
<script> | |
const onClick = () => { | |
const body = document.querySelector('body') | |
body.classList.add('lock') | |
if (!body.querySelector('.overlay')) { | |
const overlay = document.createElement('div') | |
overlay.classList.add('overlay') | |
body.appendChild(overlay) | |
} | |
console.log(`submit!`) | |
} | |
</script> | |
</head> | |
<body> | |
<button onclick="onClick()">Submit</button> | |
<script> | |
const cancelKeyEvent = (event) => { | |
if (event.target.tagName !== 'BUTTON') { | |
return true | |
} | |
if (event.detail !== 0) { | |
return true | |
} | |
if (event.pointerType === 'mouse') { | |
return true | |
} | |
console.warn(`cancelKeyEvent!`) | |
event.stopPropagation() | |
} | |
//window.addEventListener('click', cancelKeyEvent, true) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment