Created
September 17, 2020 14:51
-
-
Save vinzdef/43c8a0ea6b7aa88124179103859a5746 to your computer and use it in GitHub Desktop.
Removes outlines when using a mouse
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
import {on, off} from '@okiba/dom' | |
const outlineClass = 'is-outline-hidden' | |
function disableOutline() { | |
on(window, 'keydown', enableOutline) | |
off(window, 'mousemove', disableOutline) | |
document.body.classList.add(outlineClass) | |
} | |
function enableOutline({keyCode}) { | |
if (keyCode !== 9) return | |
off(window, 'keydown', enableOutline) | |
on(window, 'mousemove', disableOutline) | |
document.body.classList.remove(outlineClass) | |
} | |
export default function smartOutline() { | |
on(window, 'mousemove', disableOutline) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment