Summary: | CSS Animations: Restarting animations without a setTimeout doesn't work | ||
---|---|---|---|
Product: | WebKit | Reporter: | Paul Bakaus <pbakaus> |
Component: | CSS | Assignee: | Nobody <webkit-unassigned> |
Status: | VERIFIED REMIND | ||
Severity: | Normal | CC: | cabanier, dino, pbakaus, simon.fraser |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | All | ||
OS: | All | ||
URL: | http://developer.apple.com/safari/library/documentation/internetweb/conceptual/safarivisualeffectsprogguide/Animations/Animations.html |
Description
Paul Bakaus
2010-07-27 01:04:43 PDT
This isn't a problem specific to animations. It's a result of the way that browsers batch style changes. One workaround is to use offsetWidth to force the engine to to do a style resolution/layout. This bug has no testcase and does not describe a specific issue, so closing. Excuse me, how is this not a specific issue? It is such an apparent issue that even Apple is recognizing it. And yes, there is a testcase attached in the URL specified, which is best showing the significance when Apple itself needs workarounds. Thanks for the information that this is related to style change batching. This doesn't make it any better though. Might need to change a category or open another ticket. If you give me instructions about the right category, I'll go right ahead. Bump. This is a real issue. I think https://bugs.webkit.org/show_bug.cgi?id=54151 might cover this. We need to flesh out the API a little more, but it would be something like: var a = myElement.webkitGetAnimation()[0]; a.pause(); a.elapsedTime = 0; a.play(); (In reply to comment #4) > I think https://bugs.webkit.org/show_bug.cgi?id=54151 might cover this. We need to flesh out the API a little more, but it would be something like: > > var a = myElement.webkitGetAnimation()[0]; > a.pause(); > a.elapsedTime = 0; > a.play(); This looks pretty cool. Thank god you guys show us a little JS API love :) Looking forward to seeing the API stabilize. (In reply to comment #4) > I think https://bugs.webkit.org/show_bug.cgi?id=54151 might cover this. We need to flesh out the API a little more, but it would be something like: > > var a = myElement.webkitGetAnimation()[0]; > a.pause(); > a.elapsedTime = 0; > a.play(); I don't believe this will solve the problem since the event will fire asynchronously. Because of this, it will be too late by the time the JS code is executed. Correct. You simply cannot rely on DOM events for accurate timing (whether in animations or not). But the bug was about restarting an animation within the same JS cycle (so that you can avoid setTimeout). The code above would do that. |