|
20 | 20 |
|
21 | 21 | <style> |
22 | 22 | html { |
23 | | - background: #018DED url(http://unsplash.it/1500/1000?image=881&blur=5); |
| 23 | + background: #018DED url(http://unsplash.it/1500/1000?image=eyJhcHBfaWQiOjEyMDd9&blur=5); |
24 | 24 | background-size: cover; |
25 | 25 | font-family: 'helvetica neue'; |
26 | 26 | text-align: center; |
|
63 | 63 | top: 50%; |
64 | 64 | transform-origin: 100%; |
65 | 65 | transform: rotate(90deg); |
66 | | - transition: all 0.5s; |
67 | | - transition-timing-function: cubic-bezier(0.11, 2.75, 0.34, 0.99); |
68 | 66 | } |
69 | 67 |
|
70 | 68 | .hour-hand { |
|
84 | 82 | const hourHand = document.querySelector('.hour-hand'); |
85 | 83 |
|
86 | 84 |
|
| 85 | + |
87 | 86 | // We will calculate the date |
88 | 87 | function setDate() { |
| 88 | + document.querySelector('html').style.background = '#' + Math.floor(Math.random() * 16777215).toString(16);; |
89 | 89 |
|
90 | 90 | const now = new Date(); |
91 | 91 |
|
92 | 92 | const seconds = now.getSeconds(); |
| 93 | + secondHand.style.transition = (seconds === 0) ? "none" : "all 0.5s cubic-bezier(0.11, 2.75, 0.34, 0.99)"; |
93 | 94 | const secondsDegrees = ((seconds / 60) * 360) + 90; |
94 | 95 | secondHand.style.transform = `rotate(${secondsDegrees}deg)`; |
95 | 96 |
|
96 | 97 | const mins = now.getMinutes(); |
| 98 | + minsHand.style.transition = (mins === 0) ? "none" : "all 0.5s cubic-bezier(0.11, 2.75, 0.34, 0.99)"; |
97 | 99 | const minsDegrees = ((mins / 60) * 360) + 90; |
98 | 100 | minsHand.style.transform = `rotate(${minsDegrees}deg)`; |
99 | 101 |
|
100 | 102 | const hour = now.getHours(); |
| 103 | + hourHand.style.transition = (hour === 0) ? "none" : "all 0.5s cubic-bezier(0.11, 2.75, 0.34, 0.99)"; |
101 | 104 | const hourDegrees = ((hour / 12) * 360) + 90; |
102 | 105 | hourHand.style.transform = `rotate(${hourDegrees}deg)`; |
103 | 106 |
|
|
0 commit comments