jeremyckahn/shifty

Bundle all `resolve`d Promise data

jeremyckahn opened this issue · 0 comments

Currently, resolved Promise data is spread across formal parameters:

this._resolve(_currentState, _attachment)

It should be bundled into the first argument so that it can accessed via await. Additionally, the Tweenable instance should be provided to resolve. Theoretically, along with #118, this code would be possible with this change:

const run = async () => {
  let { tweenable } = await tween({
    easing: "easeInOutQuad",
    duration: 500,
    step: ({ x }) => {
      div.style.transform = `translateX(${x}%)`;
    },
    from: { x: 0 },
    to: { x: 300 }
  });

  { tweenable } = await tweenable.tween({
    to: { x: 0 }
  });

  await tweenable.tween({
    to: { x: 100 }
  });
};