From 94ac3398b79781654f7a95b2d8ee289e1ee77440 Mon Sep 17 00:00:00 2001 From: Jfreundlich01 Date: Tue, 17 May 2022 09:24:40 -0400 Subject: [PATCH] fixed hour rotation to go with minutes --- clock.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clock.js b/clock.js index d2cc028..4bd89fe 100644 --- a/clock.js +++ b/clock.js @@ -6,7 +6,7 @@ const secondHand = document.getElementById("second"); function clockRun(){ //creates date. Accesses current day and time const date = new Date(); - //console.log(date) + console.log(date) //creates hour variable. Prints to military time so out of 24 let hours = date.getHours() @@ -19,16 +19,20 @@ function clockRun(){ // creates seconds variable. Prints 0-60 let seconds = date.getSeconds() + let secondRotation = (seconds/60) + let minuteRotation = (minutes/60) + let hourRotation = (((minuteRotation) + hours)/12) + //console.log(seconds); //gets the seconds to run!! - secondHand.style.transform = "rotate(" + ((seconds/60)*360) + "deg)" + secondHand.style.transform = "rotate(" + (secondRotation * 360) + "deg)" //get the minutes to run!! - minuteHand.style.transform = "rotate(" + ((minutes/60)*360) + "deg)" + minuteHand.style.transform = "rotate(" + (minuteRotation * 360) + "deg)" //gert the hours to run! - hourHand.style.transform = "rotate(" + ((hours/12)*360) + "deg)" + hourHand.style.transform = "rotate(" + (hourRotation * 360) + "deg)" }