Skip to content

_pauseAnimationsForTesting incorrectly changes player currentTime #628

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

Open
ericwilligers opened this issue Jul 30, 2014 · 0 comments
Open

Comments

@ericwilligers
Copy link
Contributor

If a player does not have start time 0, and/or the player does not have playback rate 1, calling document.timeline._pauseAnimationsForTesting with the current timeline time will change the player's currentTime, and will change the animated element's computed style.

var target = document.getElementById('target');

var targetPlayer;

window.setTimeout(function() {
  var keyframes = [
    { width: '200px'},
    { width: '300px'}
  ];
  targetPlayer = target.animate(keyframes, 5000);
  targetPlayer.playbackRate = 0.25;
}, 2000);

function describeTarget() {
  console.log('document.timeline.currentTime = ' + document.timeline.currentTime);
  console.log('targetPlayer.startTime = ' + targetPlayer.startTime);
  console.log('targetPlayer.currentTime = ' + targetPlayer.currentTime);
  console.log('getComputedStyle(target).width = ' + getComputedStyle(target).width);
}

window.setTimeout(function() {
  describeTarget();
  var currentTime = document.timeline.currentTime;
  document.timeline._pauseAnimationsForTesting(currentTime);
  console.log('*** AFTER CALLING document.timeline._pauseAnimationsForTesting('+currentTime+') ***');
  describeTarget();

}, 4000);

leads to (with numbers rounded)

document.timeline.currentTime = 4000
targetPlayer.startTime = 2000
targetPlayer.currentTime = 500
getComputedStyle(target).width = 210
*** AFTER CALLING document.timeline._pauseAnimationsForTesting(4000) ***
document.timeline.currentTime = 4000
targetPlayer.startTime = 2000
targetPlayer.currentTime = 4000
getComputedStyle(target).width = 280
ericwilligers added a commit to ericwilligers/web-animations-js that referenced this issue Aug 12, 2014
Players may have non-zero start time, and/or playback rates other than
one. As noted in Issue web-animations#628, calling
document.timeline._pauseAnimationsForTesting with the current timeline
time will change such players' currentTime, and will change the animated
elements' computed style.

We implement a new testing method _freezeClockForTesting that avoids
changing any of the players, it simply freezes the timeline's
currentTime to the supplied time.
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