fix(animations): implement getPosition in browser animation builder#28264
fix(animations): implement getPosition in browser animation builder#28264literalpie wants to merge 0 commit intoangular:masterfrom
Conversation
153ae06 to
3c3600e
Compare
3c3600e to
73dcd72
Compare
5748528 to
93b7b76
Compare
There was a problem hiding this comment.
I'm not sure how reliable it is to use the id as the player index. Let me know if there's a better way.
93b7b76 to
5bcee93
Compare
|
Could we have a tests and have it rebased on latest head? |
026ea42 to
8afd132
Compare
|
It looks like you have already rebased and there is not an existing test suite for this class. Would you like me to make a new one in a new |
Yes, please, we need a test. |
|
presubmit Looks good. |
ef4ff3b to
7ab987d
Compare
|
@literalpie Could we get a test for this so that we can merge this? |
|
@mhevery did you see the tests I added? Sorry, I forgot to ping you when I made that change |
There was a problem hiding this comment.
There's no need to sort the full array just to get the largest total time. Also sort mutates the original array and that may not be what you want here.
There was a problem hiding this comment.
Thanks for catching that. I updated the code to use reduce instead.
There was a problem hiding this comment.
Thanks, that was quick 👍
Now that I'm looking further into it, it's surprising that the position of the longest player needs to be divided by its total time; indicating that getPosition from the delegated player is using a different convention than the group player. As you mention in the description the documentation appears to be incorrect, as it does indeed seem that the value should be fractional between 0 and 1 and not the number of milliseconds. So I suspect there is an issue in a different player that is causing this inconsistency (maybe it's just the mock player in tests??).
If the devision by longestPlayer.totalTime is to remain (which I'm doubting it should) then you'd also need to account for it being 0, similarly to what is done in setPosition.
There was a problem hiding this comment.
I think we may be stuck with the fractional value, since that's what setPosition uses. I'm assuming we want setting and getting to behave the same, and that we don't want to introduce a breaking change.
I'll update this tonight to handle 0 assuming fractional for now, and just let me know if you want me to change it.
There was a problem hiding this comment.
Yeah agreed on the fractional, I wasn't suggesting to change that. It's just that I'd expect longestPlayer.getPosition() to also be fractional already, such that the division by its total time seems to be inconsistent.
d6e5813 to
2c00466
Compare
|
@literalpie ICYMI I left an additional comment in the already resolved conversation: #28264 (comment) |
e42348b to
e6a4f31
Compare
e6a4f31 to
790d8bf
Compare
JoostK
left a comment
There was a problem hiding this comment.
Thanks for making the changes. I don't see any issues with this in its current state so happy to approve.
mhevery
left a comment
There was a problem hiding this comment.
reviewed-for: global-approvers
790d8bf to
7954c8d
Compare
|
PR accidently closed. :-( and now unable to re-open. Moved content to #39983 |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |


PR Type
What kind of change does this PR introduce?
What is the current behavior?
calling
player.getPositionalways returns 0Issue Number: #23785 #18891
What is the new behavior?
calling
player.getPositionwill return the position of the animation that is complete, as a percent (decimal) value (this is to match thesetPositionfunctionality although it does not match the docs).If
player.getPositionis called on a player with a group of animations, the returned value will be the position of the longest animation (including delays)Does this PR introduce a breaking change?
Other information
As mentioned above, the functionality does not match the documentation (which says get/set position is measured in milliseconds). I opted to have the functionality match
setPositionfor consistency.I considered changing the documentation, but unfortunately, it is a interface implemented by
CssKeyframesPlayer, which does match the documentation. Let me know if I should either include the documentation change or the functionality.I did not include tests because
AnimationGroupPlayerdoes not have any tests.