Skip to content

Commit a46ebbb

Browse files
committed
random color background
1 parent a8a4c3d commit a46ebbb

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

index.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<style>
2222
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);
2424
background-size: cover;
2525
font-family: 'helvetica neue';
2626
text-align: center;
@@ -63,8 +63,6 @@
6363
top: 50%;
6464
transform-origin: 100%;
6565
transform: rotate(90deg);
66-
transition: all 0.5s;
67-
transition-timing-function: cubic-bezier(0.11, 2.75, 0.34, 0.99);
6866
}
6967

7068
.hour-hand {
@@ -84,20 +82,25 @@
8482
const hourHand = document.querySelector('.hour-hand');
8583

8684

85+
8786
// We will calculate the date
8887
function setDate() {
88+
document.querySelector('html').style.background = '#' + Math.floor(Math.random() * 16777215).toString(16);;
8989

9090
const now = new Date();
9191

9292
const seconds = now.getSeconds();
93+
secondHand.style.transition = (seconds === 0) ? "none" : "all 0.5s cubic-bezier(0.11, 2.75, 0.34, 0.99)";
9394
const secondsDegrees = ((seconds / 60) * 360) + 90;
9495
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
9596

9697
const mins = now.getMinutes();
98+
minsHand.style.transition = (mins === 0) ? "none" : "all 0.5s cubic-bezier(0.11, 2.75, 0.34, 0.99)";
9799
const minsDegrees = ((mins / 60) * 360) + 90;
98100
minsHand.style.transform = `rotate(${minsDegrees}deg)`;
99101

100102
const hour = now.getHours();
103+
hourHand.style.transition = (hour === 0) ? "none" : "all 0.5s cubic-bezier(0.11, 2.75, 0.34, 0.99)";
101104
const hourDegrees = ((hour / 12) * 360) + 90;
102105
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
103106

0 commit comments

Comments
 (0)