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