From c51bf5e84977b687c71fd456c2f4453cffe720f7 Mon Sep 17 00:00:00 2001 From: Unicar Date: Tue, 9 Apr 2019 22:37:15 +1000 Subject: [PATCH] Updated --- index.html | 23 ++++------------------- index.js | 13 ++++++++----- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/index.html b/index.html index ae27614..f2a954d 100644 --- a/index.html +++ b/index.html @@ -12,28 +12,13 @@ +
-
+ +
- -
- - + \ No newline at end of file diff --git a/index.js b/index.js index 52c5355..4ba6205 100644 --- a/index.js +++ b/index.js @@ -48,7 +48,11 @@ function setup() { growMountains() mountains.forEach(m => m.display()) - noLoop() + if (isMoving) { + loop() + } else { + noLoop() + } } @@ -70,7 +74,9 @@ window.onload = function () { saveCanvas(canvas, 'jizhi-bg', 'jpg') }) - document.querySelector('#move').addEventListener('click', () => { + const moveBtn = document.querySelector('#move') + + moveBtn.addEventListener('click', () => { isMoving = !isMoving if (isMoving) { @@ -78,9 +84,6 @@ window.onload = function () { } else { noLoop() } - - const moveBtn = document.querySelector('#move') - moveBtn.classList.toggle('icon-pause2') moveBtn.classList.toggle('icon-play') })