From 12c9e85acd78310772a4273fd79ead26da313b00 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Sun, 29 Dec 2019 19:40:35 +0800 Subject: [PATCH] Use CSS3 animation --- waifu-tips.js | 9 +++++---- waifu.css | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/waifu-tips.js b/waifu-tips.js index 2d39b6d..40058ea 100755 --- a/waifu-tips.js +++ b/waifu-tips.js @@ -19,7 +19,7 @@ function loadWidget(waifuPath, apiPath) { `); - $("#waifu").show().animate({ bottom: 0 }, 3000); + $("#waifu").show().css({ bottom: 0 }); function registerEventListener() { document.querySelector("#waifu-tool .fa-comment").addEventListener("click", showHitokoto); @@ -46,10 +46,11 @@ function loadWidget(waifuPath, apiPath) { document.querySelector("#waifu-tool .fa-times").addEventListener("click", () => { localStorage.setItem("waifu-display", Date.now()); showMessage("愿你有一天能与重要的人重逢。", 2000, 11); - $("#waifu").animate({ bottom: -500 }, 3000, () => { + $("#waifu").css({ bottom: -500 }); + setTimeout(() => { $("#waifu").hide(); $("#waifu-toggle").show().animate({ "margin-left": -50 }, 1000); - }); + }, 3000); }); var devtools = () => {}; console.log("%c", devtools); @@ -235,7 +236,7 @@ function initWidget(waifuPath = "/waifu-tips.json", apiPath = "") { $("#waifu-toggle").attr("first-time", false); } else { localStorage.removeItem("waifu-display"); - $("#waifu").show().animate({ bottom: 0 }, 3000); + $("#waifu").show().css({ bottom: 0 }); } }); if (localStorage.getItem("waifu-display") && Date.now() - localStorage.getItem("waifu-display") <= 86400000) { diff --git a/waifu.css b/waifu.css index a8c7554..45b1ef1 100755 --- a/waifu.css +++ b/waifu.css @@ -18,7 +18,7 @@ line-height: 0; position: fixed; transform: translateY(3px); - transition: transform .3s ease-in-out; + transition: transform .3s ease-in-out, bottom 3s ease-in-out; z-index: 1; }