Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startTranslatedBy and endTranslatedBy modify the initial and final bounds width/height #491

Open
kevinkucharczyk opened this issue Jul 5, 2022 · 0 comments

Comments

@kevinkucharczyk
Copy link

Describe the bug
startTranslatedBy and endTranslatedBy work by using the shiftedBounds function to generate a new bounds DOMRect.

Let's look at endTranslatedBy:

endTranslatedBy(dx: number, dy: number) {
  this._finalBounds = shiftedBounds(this._initialBounds!, dx, dy);
}

This takes the initial coordinates, and adds the offsets to them. However, shiftedBounds also copies width and height from the initial bounds to the final bounds. This can break an animation if a sprite's dimensions change.

To Reproduce
You can add

sprite.startTranslatedBy(0, -50);

in one of the ember-animated docs examples:

and you'll see that the images lose their scale transition:
CleanShot 2022-07-05 at 14 29 21

If you then also override the initial bounds sizes:

      sprite._initialBounds.height = 60;
      sprite._initialBounds.width = 60;

you'll see that the size does transition (the position animation looks buggy though because of the fact that we're changing the initial bounds entirely):
CleanShot 2022-07-05 at 14 31 24

Expected behavior
startTranslatedBy and endTranslatedBy should only change the x/y coordinates, not the dimensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant