|
61 | 61 | background:black; |
62 | 62 | position: absolute; |
63 | 63 | top:50%; |
64 | | -transform-origin:100%; |
| 64 | +transform-origin:right; /*same as transform-origin:100%. Use values over 100% to transfrom about a point off the object*/ |
65 | 65 | transform:rotate(90deg); |
66 | 66 | transition: all 0.05s; |
67 | | -transition-timing-function:cubic-bezier(0.1,2.7,0.58,1); |
| 67 | +transition-timing-function:cubic-bezier(0,2.7,0.58,1); |
68 | 68 | } |
69 | | -</style> |
70 | 69 |
|
71 | | -<script> |
72 | | -constsecondHand=document.querySelector('.second-hand'); |
73 | | -constminsHand=document.querySelector('.min-hand'); |
74 | | -consthourHand=document.querySelector('.hour-hand'); |
| 70 | +</style> |
75 | 71 |
|
76 | | -functionsetDate(){ |
77 | | -constnow=newDate(); |
| 72 | +<script> |
78 | 73 |
|
79 | | -constseconds=now.getSeconds(); |
80 | | -constsecondsDegrees=((seconds/60)*360)+90; |
81 | | -secondHand.style.transform=`rotate(${secondsDegrees}deg)`; |
| 74 | +constsecondHand=document.querySelector('.second-hand'); |
| 75 | +constminuteHand=document.querySelector('.min-hand'); |
| 76 | +consthourHand=document.querySelector('.hour-hand'); |
82 | 77 |
|
83 | | -constmins=now.getMinutes(); |
84 | | -constminsDegrees=((mins/60)*360)+90; |
85 | | -minsHand.style.transform=`rotate(${minsDegrees}deg)`; |
86 | | - |
87 | | -consthour=now.getMinutes(); |
88 | | -consthourDegrees=((mins/12)*360)+90; |
89 | | -hourHand.style.transform=`rotate(${hourDegrees}deg)`; |
90 | | -} |
| 78 | +functionsetDate(){ |
| 79 | +constnow=newDate(); |
| 80 | +constseconds=now.getSeconds(); |
| 81 | +constminutes=now.getMinutes(); |
| 82 | +consthours=now.getHours(); |
| 83 | +constsecondsDegrees=(seconds*6)+90/*(seconds/60 * 360) = seconds * 6)*/ |
| 84 | +constminutesDegrees=(minutes*6)+90 |
| 85 | +consthoursDegrees=(hours*30)+90/*360/12 = 30 */ |
| 86 | +secondHand.style.transform=`rotate(${secondsDegrees}deg)`; |
| 87 | +minuteHand.style.transform=`rotate(${minutesDegrees}deg)`; |
| 88 | +hourHand.style.transform=`rotate(${hoursDegrees}deg)`; |
| 89 | +} |
91 | 90 |
|
92 | | -setInterval(setDate,1000); |
| 91 | +setInterval(setDate,1000);/*built in function that runs a function at a given period |
| 92 | + document.querySelector(`.second-hand');*/ |
93 | 93 |
|
94 | | -</script> |
| 94 | +</script> |
95 | 95 | </body> |
96 | 96 | </html> |
0 commit comments