Skip to content
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

Browser-independent way of doing request animation frame. #2185

Closed
munificent opened this issue Mar 15, 2012 · 7 comments
Closed

Browser-independent way of doing request animation frame. #2185

munificent opened this issue Mar 15, 2012 · 7 comments
Assignees

Comments

@munificent
Copy link
Member

dart:html exposes webkitRequestAnimationFrame, but that means when compiled to JS it won't work in Firefox or IE. Ideally, it would just expose requestAnimationFrame() and the generated JS would detect and use the appropriate one:

requestID = window.mozRequestAnimationFrame(callback); // Firefox
window.msRequestAnimationFrame(callback); // IE 10 PP2+
window.webkitRequestAnimationFrame(callback[, element]); // Chrome/Webkit

@DartBot
Copy link

DartBot commented Apr 11, 2012

This comment was originally written by @bp74


I just ran into the same problem. My current project is porting a Flash game to Dart/HTML5 and if i can't use the "RequestAnimationFrame" cross browser it is really bad. Please address this issue soon.

@jacob314
Copy link
Member

We need to add $dom_mozRequestAnimationFrame to dart:html or implement a generic scheme of providing multiple optional native bindings for a native method.
for example, the ideal terse code for this might be:

void requestAnimationFrame(AnimationFrameCallback callback) "webkitRequestAnimationFrame,mozRequestAnimationFrame" {
  setTimeout(callback, 0);
}

Which means use webkitRequestAnimationFrame or mozRequestAnimation frame if available
otherwise fallback to using setTimeout 0.


Set owner to @rakudrama.

@DartBot
Copy link

DartBot commented Apr 12, 2012

This comment was originally written by @bp74


Thank you jacob, that sounds good. I have another suggestion:

You could remove "webkitRequestAnimationFrame" and add the standard compliant "requestAnimationFrame" declaration. Now i add some JavaScript code (see below) to my page ... this should work right? I can't test it because the Dart2JS Compiler does not work with the latest builds of the Dart Editor :(

<pre>
if ( !window.requestAnimationFrame ) {
  window.requestAnimationFrame = ( function() {
    return window.webkitRequestAnimationFrame ||
                window.mozRequestAnimationFrame ||
                window.oRequestAnimationFrame ||
                window.msRequestAnimationFrame ||
                function(callback) {
                   window.setTimeout( callback, 1000 / 60, new Date()); };
    } )();
}
</pre>

I think Chrome AND Firefox (and IE 10) support "requestAnimationFrame" allready, right?

@rakudrama
Copy link
Member

Reference: 'A robust polyfill' at
http://paulirish.com/2011/requestanimationframe-for-smart-animating/

@vsmenon
Copy link
Member

vsmenon commented Apr 13, 2012

Removed Area-UI label.
Added Area-DOM label.

@DartBot
Copy link

DartBot commented Apr 21, 2012

This comment was originally written by @bp74


Thank you very much, the latest build 6825 has got the new implementation, it works great!

@rakudrama
Copy link
Member

Added Fixed label.

copybara-service bot pushed a commit that referenced this issue Aug 14, 2023
Revisions updated by `dart tools/rev_sdk_deps.dart`.

lints (https://github.com/dart-lang/lints/compare/1e0245e..54cd7a0):
  54cd7a0  2023-08-11  Parker Lougheed  Cleanup docs and links (#142)

protobuf (https://github.com/dart-lang/protobuf/compare/217c030..a852ba4):
  a852ba4  2023-08-14  Ömer Sinan Ağacan  Release protobuf-3.1.0, protoc_plugin-21.1.0 (#868)
  8505c58  2023-08-14  Ömer Sinan Ağacan  Generate constructor arguments again, add a flag to disable (#855)

test (https://github.com/dart-lang/test/compare/9b1828f..bc0a992):
  bc0a992d  2023-08-11  Nate Bosch  Remove always null observatoryUrl for browsers (#2079)

webdev (https://github.com/dart-lang/webdev/compare/f8f752c..19aad27):
  19aad27b  2023-08-11  Elliott Brooks  Reset DWDS to version 20.0.2-wip after release (#2193)
  20cc6d3d  2023-08-10  Elliott Brooks  Prepare DWDS for release to version 20.0.1 (#2192)
  9e352670  2023-08-10  Elliott Brooks  Prepare DWDS for release to version 20.0.0 (#2191)
  bc008840  2023-08-10  Bernardo Ferrari  Update `file` dependency. (#2185)
  afbd6401  2023-08-10  Elliott Brooks  Re-enable events_test with fix (#2189)
  1f1efa35  2023-08-10  Elliott Brooks  Fix Flutter crash by catching WipError on resume and mapping to RPC error (#2188)

Change-Id: I159fc1b35b60bab9909f287a9c9f85b624993fb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/320640
Commit-Queue: Konstantin Shcheglov <[email protected]>
Auto-Submit: Devon Carew <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
This issue was closed.
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

5 participants