Mclilzee / zap-simulator

Zap Matrix Simulator
https://mclilzee.github.io/zap-simulator/
Other
4 stars 16 forks source link

Add named variables to querySelector. #2

Closed JuanDCeballos closed 2 years ago

JuanDCeballos commented 2 years ago

Changes.

Instead of just document.querySelector an element and then attach the eventListerner to itself.

document.querySelector('.example').addEventListener('click', () => {
// some juicy code here
})

What about to store that element on a variable and the attach the event listener to that variable. Something like this:

const exampleVarible = document.querySelector('.example');

exampleVariable.addEventListener('click', () => {
// some juicy code here
})

Benefits

This could improve code readability and code reuse.

Let me know what do you think, I could work on this one, Happy to contribute to this project.

Mclilzee commented 2 years ago

I just realized your last message after i closed it. sorry for that, if you want to contribute to the project, i'm weak in the mobile styling, adapting this to work better on mobiles would be really appreciated!.