Created
May 3, 2024 01:30
-
-
Save airhorns/e1a174b7c647e82752b00a5db61d78c1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function toast(text, delay){ | |
var div = document.createElement("div"); | |
div.style.position = "fixed"; | |
div.style.maxWidth = "80%"; | |
div.style.color = "white"; | |
div.style.boxSizing = "border-box"; | |
div.style.background = "rgba(0,0,0,0.76)"; | |
div.style.padding = "0.8em 2.618em"; | |
div.style.bottom = '9%'; | |
div.style.left = '3%'; | |
div.style.zIndex = 999999999; | |
div.style.borderRadius = "5px"; | |
div.style.opacity = "0"; | |
div.innerText = text; | |
document.body.appendChild(div); | |
div.style.marginTop = (-div.offsetHeight/2) + "px"; | |
setTimeout(function(){ | |
div.style.marginTop = (-div.offsetHeight) + "px"; | |
div.style.transition = "all 0.3s"; | |
div.style.opacity = "1"; | |
setTimeout(function(){ | |
div.style.opacity = "0"; | |
div.style.marginTop = (-div.offsetHeight/2) + "px"; | |
setTimeout(function(){ | |
document.body.removeChild(div); | |
},300); | |
}, 3000); | |
}, 0); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment