mattdesl / gsap-promise

promise wrapper for gsap (TweenLite)
MIT License
48 stars 10 forks source link

from/to states passed in should not be mutated #5

Closed cheapsteak closed 8 years ago

cheapsteak commented 8 years ago

Problem:

import animate from 'gsap-promise';

const from = {opacity: 0};
const to = {opacity: 1};

Promise.all([
    animate.fromTo(el1, 0.5, from, to),
    animate.fromTo(el2, 0.5, from, to),
])

The first promise never resolves because the onComplete is overwritten by the second call

This would be solved if the object is shallow cloned before having options added on by the library

Current workaround

Defensively clone everything passed into gsap-promise

Promise.all([
    animate.fromTo(el1, 0.5, {...from}, {...to}),
    animate.fromTo(el2, 0.5, {...from}, {...to}),
])
mattdesl commented 8 years ago

:+1: We can use object-assign for this.

cheapsteak commented 8 years ago

pushed fix to master along with new test would adding a dependency justify bumping a minor version or should it just be a patch?

mattdesl commented 8 years ago

Just a patch since the API didn't change and there are no new features added