-
Notifications
You must be signed in to change notification settings - Fork 90
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
[WIP] scale bounding client rect #48
base: master
Are you sure you want to change the base?
[WIP] scale bounding client rect #48
Conversation
e7ead64
to
31f1719
Compare
@ef4 before I bring this further, perhaps you could sanity check my approach? |
Thanks for working on this. The key question here is what Right now, some motions do account for scaling, and that is probably what is messing up your containers. Their default motion (Resize) is already accounting for scale, so you would need to take that out: see ember-animated/addon/motions/resize.js Lines 25 to 26 in 6f517fe
The smallest change that would fix the bug here is making Move understand the cumulative transforms, the same way Resize does. Probably here: ember-animated/addon/motions/move.js Lines 27 to 32 in 6f517fe
But in general, I agree with the goal of making it so that motions don't need to individually understand the surrounding cumulative transform. In the most general case, you may be animating inside an Element that is also animating its own scale. The way to make that kind of situation tenable is to keep motions thinking in relative terms. That's why |
addon/-private/sprite.js
Outdated
@@ -435,7 +435,7 @@ export default class Sprite { | |||
} | |||
this._inInitialPosition = true; | |||
if (this._offsetSprite) { | |||
this._initialBounds = relativeBounds(this.element.getBoundingClientRect(), this._offsetSprite.initialBounds); | |||
this._initialBounds = relativeBounds(this._getScaledBoundingClientRect(), this._offsetSprite.initialBounds); | |||
} else { | |||
this._initialBounds = this.element.getBoundingClientRect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this branch of the if
needs to follow the same coordinate system as the other, so your change would need to go here too.
addon/-private/sprite.js
Outdated
@@ -461,6 +461,38 @@ export default class Sprite { | |||
this._finalCumulativeTransform = cumulativeTransform(this.element); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now causing us to calculate the cumulative transform twice. I think this line can just become this._finalCumulativeTransform = this.cumulativeTransform
, and then it will share the cache.
Thanks for the feedback @ef4. I've made those changes and almost everything seems to work: There is an issue in the hero demo, possibly because it animates There are three failing tests, one is related the the hero issue above. The other two seem like they might just need to be updated to test correct values. |
470f9f9
to
e315228
Compare
e315228
to
d7a3be3
Compare
@ef4 I'm having a little trouble determining if the three failing tests are due to a bug with scaling or if the tests need to be changes now that we handle scaled containers. Perhaps you could let me know if it's obvious to you? |
A WIP PR to address #46
TODO:
Acceptance | hero
1️⃣Unit | sprite
2️⃣_getScaledBoundingClientRect
?This seems seems to fix movement of sprites when in a scaled container:
There still seems to be some issues to solve with containers:
Although these seem to be present on master too: