diff --git a/renda.js b/renda.js new file mode 100644 index 0000000..6ee75c9 --- /dev/null +++ b/renda.js @@ -0,0 +1,36 @@ +"use strict"; +const body = document.querySelector("body"); +const background = document.querySelector(".background"); +const countDisplay = document.querySelector(".countDisplay"); +const result = document.querySelector(".result"); + +let count = 0; + + +const eventType = window.ontouchstart !== null ? "click" : "touchstart"; +const addCount = function (e) { + + count++; + countDisplay.textContent = count; + +}; + +const shrinkAnim = function () { + body.removeEventListener(eventType, shrinkAnim); + body.addEventListener(eventType, addCount); + background + .animate( + {offset: [0, 0.9],}, + { duration: 3000, fill: "forwards" } + ) + .finished + .then(() => { + body.removeEventListener(eventType, addCount); + result.textContent = "はじめに戻る"; + result.classList.add("blink"); + result.addEventListener("click", () => { + location.reload(); + }); + }); +}; +body.addEventListener(eventType, shrinkAnim); \ No newline at end of file