mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Stack toasts
This commit is contained in:
parent
c2629b5c3f
commit
cd17f52b74
2 changed files with 42 additions and 7 deletions
|
@ -1,5 +1,17 @@
|
|||
import './toast.scss';
|
||||
|
||||
let toastContainer;
|
||||
|
||||
function getToastContainer() {
|
||||
if (!toastContainer) {
|
||||
toastContainer = document.createElement('div');
|
||||
toastContainer.classList.add('toastContainer');
|
||||
document.body.appendChild(toastContainer);
|
||||
}
|
||||
|
||||
return toastContainer;
|
||||
}
|
||||
|
||||
function remove(elem) {
|
||||
setTimeout(function () {
|
||||
elem.parentNode.removeChild(elem);
|
||||
|
@ -8,7 +20,7 @@ function remove(elem) {
|
|||
|
||||
function animateRemove(elem) {
|
||||
setTimeout(function () {
|
||||
elem.classList.remove('toastVisible');
|
||||
elem.classList.add('toastHide');
|
||||
remove(elem);
|
||||
}, 3300);
|
||||
}
|
||||
|
@ -24,7 +36,7 @@ export default function (options) {
|
|||
elem.classList.add('toast');
|
||||
elem.textContent = options.text;
|
||||
|
||||
document.body.appendChild(elem);
|
||||
getToastContainer().appendChild(elem);
|
||||
|
||||
setTimeout(function () {
|
||||
elem.classList.add('toastVisible');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue