File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6565 transform : rotate (90deg );
6666 transition : all 0.5s
6767 transition-timing-function: cubic-bezier (1 , 2.99 , 0.58 , 1 );
68-
6968 }
7069
7170 </ style >
7271 < script >
73- setInterval ( tick , 1000 )
74- function tick ( ) {
75- const date = new Date ( ) ;
76- const seconds = date . getSeconds ( ) ;
77- secTick ( date . getSeconds ( ) )
78- minuteTick ( date . getMinutes ( ) )
79- hourTick ( date . getHours ( ) )
80- }
81- function secTick ( sec ) {
82- const secondsDegrees = sec * 6 ;
83- const handSec = document . querySelector ( '.hand.second-hand' ) ;
84- handSec . style . transform = `rotate(${ secondsDegrees } deg)` ;
85- }
86- function minuteTick ( min ) {
87- const minDegrees = min * 6 ;
88- const handMin = document . querySelector ( '.hand.min-hand' ) ;
89- handMin . style . transform = `rotate(${ minDegrees } deg)` ;
90- }
91- function hourTick ( hour ) {
92- const hourDegrees = hour * 30 ;
93- const handHour = document . querySelector ( '.hand.hour-hand' ) ;
94- handHour . style . transform = `rotate(${ hourDegrees } deg)` ;
95- }
96-
9772 </ script >
9873</ body >
9974</ html >
Original file line number Diff line number Diff line change @@ -27,7 +27,9 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
2727 */
2828
2929 body {
30- text-align : center;
30+ display : flex;
31+ justify-content : center;
32+ flex-wrap : wrap;
3133 }
3234
3335 body {
@@ -45,9 +47,35 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
4547 input {
4648 width : 100px ;
4749 }
50+
51+ : root {
52+ --base : # ffc600 ;
53+ --blur : 10px ;
54+ --padding : 10px ;
55+ }
56+
57+ img {
58+ background : var (--base );
59+ filter : blur (var (--blur ));
60+ padding : var (--spacing );
61+ }
62+
63+ .hl {
64+ color : var (--base );
65+ }
4866 </ style >
4967
5068 < script >
69+ var inputs = document . querySelectorAll ( '.controls input' ) ;
70+
71+ function handleUpdate ( ) {
72+ debugger
73+ const suffix = this . dataset . sizing || '' ;
74+ document . documentElement . style . setProperty ( `--${ this . name } ` , this . value + suffix )
75+ }
76+
77+ inputs . forEach ( input => input . addEventListener ( 'change' , handleUpdate ) ) ;
78+ inputs . forEach ( input => input . addEventListener ( 'mousemove' , handleUpdate ) ) ;
5179 </ script >
5280
5381</ body >
You can’t perform that action at this time.
0 commit comments