rileyjshaw / sweep

:rainbow: A JavaScript library for smooth color transitions
http://rileyjshaw.com/sweep/
MIT License
444 stars 31 forks source link

Non-DOM color change API #8

Open jamesplease opened 5 years ago

jamesplease commented 5 years ago

It'd be useful if this lib supported a transition function that was separate from the DOM. The current API does two things for you:

  1. transitions the colors
  2. updates the DOM

It's convenient that it does both, but tying them together also limits the portability of the lib, as it prevents you from transitioning colors outside of the DOM transforms that this lib supports.

Consider a function like:

transition({ fromColor, toColor, onUpdate, duration, direction, ...etc });

where onUpdate receives the current color as its first arg. This would allow the library to be used in more contexts, such as headless environments (i.e.; Node), as well as additional DOM contexts, such as canvas.