Skip to content

fix(animations): implement getPosition in browser animation builder#28264

Closed
literalpie wants to merge 0 commit intoangular:masterfrom
literalpie:browser-animation-get-position
Closed

fix(animations): implement getPosition in browser animation builder#28264
literalpie wants to merge 0 commit intoangular:masterfrom
literalpie:browser-animation-get-position

Conversation

@literalpie
Copy link
Contributor

@literalpie literalpie commented Jan 20, 2019

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

calling player.getPosition always returns 0
Issue Number: #23785 #18891

What is the new behavior?

calling player.getPosition will return the position of the animation that is complete, as a percent (decimal) value (this is to match the setPosition functionality although it does not match the docs).

If player.getPosition is 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?

  • Yes
  • No

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 setPosition for 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 AnimationGroupPlayer does not have any tests.

@literalpie literalpie requested review from a team January 20, 2019 16:04
@literalpie literalpie force-pushed the browser-animation-get-position branch 2 times, most recently from 153ae06 to 3c3600e Compare January 20, 2019 16:16
@literalpie literalpie closed this Jan 20, 2019
@literalpie literalpie force-pushed the browser-animation-get-position branch from 3c3600e to 73dcd72 Compare January 20, 2019 16:20
@literalpie literalpie reopened this Jan 20, 2019
@literalpie literalpie force-pushed the browser-animation-get-position branch from 5748528 to 93b7b76 Compare January 20, 2019 16:28
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@literalpie literalpie force-pushed the browser-animation-get-position branch from 93b7b76 to 5bcee93 Compare January 20, 2019 16:34
@ngbot ngbot bot added this to the needsTriage milestone Jan 23, 2019
@pullapprove pullapprove bot requested review from alxhub and matsko April 17, 2020 14:23
Copy link

@rock-bolton-hyland rock-bolton-hyland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a quality a PR

@mhevery
Copy link
Contributor

mhevery commented Nov 20, 2020

Could we have a tests and have it rebased on latest head?

@mhevery mhevery self-assigned this Nov 20, 2020
@pullapprove pullapprove bot requested review from jelbourn and removed request for matsko November 20, 2020 23:43
@mhevery mhevery force-pushed the browser-animation-get-position branch 3 times, most recently from 026ea42 to 8afd132 Compare November 21, 2020 00:06
@literalpie
Copy link
Contributor Author

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 animations/test/animation_group_player_spec.ts file?

@mhevery
Copy link
Contributor

mhevery commented Nov 23, 2020

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 animations/test/animation_group_player_spec.ts file?

Yes, please, we need a test.

@mhevery
Copy link
Contributor

mhevery commented Nov 23, 2020

presubmit Looks good.

@literalpie literalpie force-pushed the browser-animation-get-position branch 2 times, most recently from ef4ff3b to 7ab987d Compare November 24, 2020 02:03
@mhevery
Copy link
Contributor

mhevery commented Dec 2, 2020

@literalpie Could we get a test for this so that we can merge this?

@literalpie
Copy link
Contributor Author

@mhevery did you see the tests I added? Sorry, I forgot to ping you when I made that change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that. I updated the code to use reduce instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

@literalpie literalpie Dec 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@literalpie literalpie force-pushed the browser-animation-get-position branch 3 times, most recently from d6e5813 to 2c00466 Compare December 2, 2020 22:17
@JoostK
Copy link
Member

JoostK commented Dec 2, 2020

@literalpie ICYMI I left an additional comment in the already resolved conversation: #28264 (comment)

@literalpie literalpie force-pushed the browser-animation-get-position branch from e42348b to e6a4f31 Compare December 3, 2020 01:56
@mhevery mhevery force-pushed the browser-animation-get-position branch from e6a4f31 to 790d8bf Compare December 4, 2020 01:12
Copy link
Member

@JoostK JoostK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes. I don't see any issues with this in its current state so happy to approve.

Copy link
Contributor

@mhevery mhevery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed-for: global-approvers

@mhevery
Copy link
Contributor

mhevery commented Dec 4, 2020

presubmit deflake

@mhevery mhevery added the target: patch This PR is targeted for the next patch release label Dec 5, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Dec 5, 2020
@mhevery mhevery added the action: merge The PR is ready for merge by the caretaker label Dec 5, 2020
@ngbot
Copy link

ngbot bot commented Dec 5, 2020

I see that you just added the action: merge label, but the following checks are still failing:
    failure conflicts with base branch "master"
    pending 2 pending code reviews

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@mhevery
Copy link
Contributor

mhevery commented Dec 5, 2020

PR accidently closed. :-( and now unable to re-open. Moved content to #39983

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 5, 2021
@ngbot ngbot bot removed this from the Backlog milestone Jan 5, 2021
@literalpie literalpie deleted the browser-animation-get-position branch January 5, 2021 17:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants