[WIP] scale bounding client rect#48
[WIP] scale bounding client rect#48GavinJoyce wants to merge 1 commit intoember-animation:masterfrom
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
| 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.
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.
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 | hero1️⃣Unit | sprite2️⃣_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: