Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
a complete rewrite of particleground.js
only a third file size (to be fair: without jQuery-stuff and, raf polyfill), better performance, and some additional options.
even if it has almost no impact on the performance, code like this...
...is bloat! What is wrong with:
The thing that really hits performance is the drawing routine. It is possible to only call
ctx.stroke()
once in a frame and leave the ctx style properties totally untouched, combine positioning and drawing into a single loop, avoid clunky Particle-Objects, and the ugly switch statements,even if there is no equal codebase anymore, you maybe want to merge some of these _ideas_ into your library:
orientationSupport && !desktop
- when you get a proper event in the callback, you know that you have supportpointerX - (winW / 2)
could be calculated in the mousemove and orientation handler)stackPos
thing and just use the index of the array you keep the particles in.