rileyjshaw / sweep

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

Allow animations to be stopped part-way through #4

Closed rileyjshaw closed 9 years ago

rileyjshaw commented 9 years ago

Calling sweep(...) should return a reference to the animation object that can be cancelled at any time. We probably don't want the object to be directly editable.

// starts the animation
var obj = sweep(document.querySelector('p'), 'color', 'red', 'blue');

// stops the animation
sweep(obj, 'stop');

If we're just dealing with the animation object itself, adding

sweep(obj, 'resume');

is trivial: just push it back onto the batch array.

rileyjshaw commented 9 years ago

This is a bad idea. I just implemented it and it's awkward.

Better idea:

// starts the animation
var obj = sweep(document.querySelector('p'), 'color', 'red', 'blue');

// stops the animation
obj.pause();

// resumes the animation
obj.resume();