Design comparison
Solution retrospective
This is my first javascript challenge, so I really need a lot of feedbacks >w<
Sometimes matchMedia() works responsively, sometimes it doesn't. Any idea how I can make it consistently working? Would appreciate your help :)
Community feedback
- @thiago-hdsPosted about 3 years ago
Hi erelita! Great solution! It looks really close to the design.
About the Javascript: it's not a good idea to add click handlers every time you hit the breakpoint. That way you might end up adding multiple handlers to the button that do the same thing and it's bad for performance.
You could remove the previous handler before adding a new one but I think a better solution is to use JavaScript only to toggle the class that controls the visibility of the tooltip when the button is clicked. Let the CSS/media queries control how it should look. That way you also don't need to repeat it on the HTML markup.
Hope this is helpful! 🙂
Marked as helpful1@ereljapcoPosted about 3 years ago@thiago-hds Thank you so much for your feedback! :)
I removed the matchMedia() and did what you recommended. I realized that I have used the same code for the tooltip-mobile and tooltip-desktop. LOL.
It was a lot easier and responsive now thanks to you.
Cheers! :)
1
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord