File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
1313
1414 < label for ="blur "> Blur:</ label >
1515 < input type ="range " name ="blur " min ="0 " max ="25 " value ="10 " data-sizing ="px ">
16+ <!-- data-sizing is a custom attribute to specify the suffix of the css property -->
1617
1718 < label for ="base "> Base Color</ label >
1819 < input type ="color " name ="base " value ="#2e8efc ">
@@ -75,10 +76,12 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
7576 const inputs = document . querySelectorAll ( ".controls input" ) ;
7677
7778 function handleUpdate ( ) {
78- console . log ( this . value ) ;
79+ const suffix = this . dataset . sizing || '' ;
80+ document . documentElement . style . setProperty ( `--${ this . name } ` , this . value + suffix )
7981 }
8082
81- inputs . forEach ( input => input . addEventListener ( 'change' , handleUpdate ) ) ;
83+ inputs . forEach ( input => input . addEventListener ( 'change' , handleUpdate ) ) ; /*updates when you let go*/
84+ inputs . forEach ( input => input . addEventListener ( 'mousemove' , handleUpdate ) ) ; /*changes when moved*/
8285
8386 </ script >
8487
You can’t perform that action at this time.
0 commit comments