@mattstuddert
Posted
Hey Alex, awesome work on this challenge! Your solution to the delay is absolutely fine. You could tie your CSS and JS values together inlining the transition time in your HTML using a Custom Property and then accessing it in your CSS and JS. But, I wouldn't say that's a better solution than just hardcoding the delay value in this instance.
@alex-kim-dev
Posted
Thank you, Matt! I'm pretty much enjoying Frontend Mentor, thanks for all the challenges! I had no idea i can pull out ccs variables in JS. That's awesome! Will update this solution in a bit.
@mattstuddert
Posted
@Alex-K1m you're welcome! Yeah, you can set it in your HTML like this: <div style="--transition-duration: 0.2s;">
and then access it in both your CSS and JS to tie them both to that single declaration. That can get a bit messy though. Another way is detailed in this How to get CSS values in JavaScript article, which would be a good approach.