1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/components/toast/toast.js

35 lines
689 B
JavaScript
Raw Normal View History

2020-08-14 08:46:34 +02:00
import './toast';
2018-10-23 01:05:09 +03:00
function remove(elem) {
setTimeout(function () {
elem.parentNode.removeChild(elem);
}, 300);
}
2018-10-23 01:05:09 +03:00
function animateRemove(elem) {
setTimeout(function () {
elem.classList.remove('toastVisible');
remove(elem);
}, 3300);
}
export default function (options) {
if (typeof options === 'string') {
options = {
text: options
};
}
2020-07-27 10:30:24 +01:00
const elem = document.createElement('div');
2020-09-08 15:43:19 -04:00
elem.classList.add('toast');
elem.innerHTML = options.text;
document.body.appendChild(elem);
setTimeout(function () {
elem.classList.add('toastVisible');
animateRemove(elem);
}, 300);
}