From 29953be594cc33bd28ed879a0ec0446d247c4f6f Mon Sep 17 00:00:00 2001 From: "yacheng.sz" Date: Mon, 16 Dec 2019 15:23:01 +0800 Subject: [PATCH] fix: hideToastWindow --- packages/toast/src/web/index.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/toast/src/web/index.ts b/packages/toast/src/web/index.ts index 0be894cc..73631e9e 100644 --- a/packages/toast/src/web/index.ts +++ b/packages/toast/src/web/index.ts @@ -36,29 +36,23 @@ let styles = { function showToastWindow(message: string): void { if (!toastWin) { toastWin = document.createElement('div'); - for (let key in styles.container) { toastWin.style[key] = styles.container[key]; } - document.body.appendChild(toastWin); } toastWin.textContent = message; toastWin.style.transform = 'translateX(-50%)'; toastWin.style.webkitTransform = 'translateX(-50%)'; - - // setTimeout(() => { - // toastWin.style.backgroundColor = 'rgba(0, 0, 0, 0.6)'; - // }, 0); } function hideToastWindow(): void { - if (!toastWin) return; - setTimeout((): void => { - toastWin.style.transform = 'translateX(-50%) scale(0.8)'; - toastWin.style.webkitTransform = 'translateX(-50%) scale(0.8)'; + if (toastWin && toastWin.style) { + toastWin.style.transform = 'translateX(-50%) scale(0.8)'; + toastWin.style.webkitTransform = 'translateX(-50%) scale(0.8)'; + } }, 0); }