yiliansource / party-js

A JavaScript library to brighten up your user's site experience with visual effects!
https://party.js.org
MIT License
994 stars 45 forks source link

Improve Module specification #55

Closed yiliansource closed 3 years ago

yiliansource commented 3 years ago

Is your feature request related to a problem? Please describe. Adding new modules to emitters is a bit janky, and there are a lot of cluttered module files that basically all do the same.

Describe the solution you'd like Instead of having a lot of module classes that function similarly, we could generate modules through a builder, where users can, through chaining, specify the driven property, the value and what it's driven by (lifetime/size).

Example

new ModuleBuilder()
    .drive("size")
    .by((t) => t * 2)
    .through("lifetime")
    .build();
yiliansource commented 3 years ago

Implemented using the proposed example.

Additionally, module builders can use the relative() chain to apply the value relative to the original value.