Created
January 10, 2021 06:05
-
-
Save artzub/3f2ea3932801d13a1c1fde402f407236 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
const translate = (x, y) => `transform: translate(${x}px, ${y}px)`; | |
const show = (element) => { | |
const rect = element?.getBoundingClientRect(); | |
let opacity = 0; | |
if (rect) { | |
opacity = 1; | |
leftTop.setAttribute('style', translate(rect.left, rect.top)); | |
leftBottom.setAttribute('style', translate(rect.left, rect.bottom)); | |
rightTop.setAttribute('style', translate(rect.right, rect.top)); | |
rightBottom.setAttribute('style', translate(rect.right, rect.bottom)); | |
} | |
overlay.setAttribute('style', `opacity: ${opacity}`); | |
}; | |
const hide = () => { | |
show(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment