K
K
konstant1n132020-04-27 07:43:49
JavaScript
konstant1n13, 2020-04-27 07:43:49

What are the notes to JS slider?

Made a slider in pure JS. I would like to hear how to do better and in general how to move forward in learning. I will be grateful for all the criticism and advice.
Slider: https://konstantinkot.github.io/Slider/
Repository: https://github.com/konstantinkot/Slider

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Bogachev, 2020-04-27
@sfi0zy

By functionality:

  • Sometimes the buttons "left" and "right" freeze, do not respond for several seconds.
  • When moving from the last slide to the first, they all flash. It would be cool if there was just a transition, like between the rest.
  • You can’t use it from the keyboard, swipes are also not supported.
  • At the beginning there is something like document.querySelectorAll in abundance. This hints that two sliders on the same page will not work (everything will be mixed together).

By code:
  • The code is horribly formatted. It is difficult to read (read difficult to maintain). Check out at least the Airbnb JavaScript Style Guide and understand why code should be readable. There's also a mix of ES6+ and some ancient hacks with that=this, self-calling functions, and so on. You are already using a modern language - so use only it. The code will be much simpler in structure. Now the devil's leg will break there. And very very very very very long functions also make it difficult to navigate what is happening.
  • Pointless comments. They just duplicate code.
  • It is better to download third-party code via NPM and connect it from node_modules, rather than copy it yourself, and even more so, you should not mix different tools into one file by hand. And yes, are they used there at all or just lie there?
  • The repository does not contain configs and assembly instructions. All this should be. Without them, it is not clear how to rebuild it at all.

Recommendations:
  • Read about code style, how to write simply and clearly. It's better to learn it right away.
  • Google how and why to write comments (and how to generate documentation from them).
  • Understand why you need all the standard tools - builders, preprocessors, linters, package managers, version control systems, etc. This understanding will raise your crafts to a new level in terms of their further reuse. Yes, and it will help you in your work.
  • Test. At least manually.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question