Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 1014843004: Make Element.animate work in dart2js Chrome (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix line length Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 8e2976493468388a1121fe8aad378c759d571485..453cf20e5876ff64ae8556a4979ab21ae597577a 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -385,6 +385,9 @@ class AnimationPlayer extends EventTarget {
// To suppress missing implicit constructor warnings.
factory AnimationPlayer._() { throw new UnsupportedError("Not supported"); }
+ /// Checks if this type is supported on the current platform.
+ static bool get supported => JS('bool', '!!(document.body.animate)');
+
@DomName('AnimationPlayer.currentTime')
@DocsEditable()
@Experimental() // untriaged
@@ -11198,6 +11201,51 @@ abstract class Element extends Node implements GlobalEventHandlers, ParentNode,
void leftView() {}
/**
+ * Creates a new AnimationEffect object whose target element is the object
+ * on which the method is called, and calls the play() method of the
+ * AnimationTimeline object of the document timeline of the node document
+ * of the element, passing the newly created AnimationEffect as the argument
+ * to the method. Returns an AnimationPlayer for the effect.
+ *
+ * Examples
+ *
+ * var animation = elem.animate([{"opacity": 75}, {"opacity": 0 }, 200);
+ *
+ * var animation = elem.animate([
+ * {"transform": "translate(100px, -100%)"},
+ * {"transform" : "translate(400px, 500px)"}
+ * ], 1500);
+ *
+ * The [frames] parameter is a List<Map>, where the
+ * map entries specify CSS animation effects. The
+ * [timing] paramter can be a double, representing the number of milliseconds
+ * for the transition, or a Map with fields corresponding to those
+ * of the [Timing] object.
+ *
+ * This is not yet supported in Dartium.
+ **/
+// TODO(alanknight): Correct above comment once it works in Dartium.
+ @Experimental
+ @SupportedBrowser(SupportedBrowser.CHROME, '36')
+ AnimationPlayer animate(List<Map<String, dynamic>> frames, [timing]) {
+ // If frames is an AnimationEffect, leave it alone?
+ var convertedFrames = frames;
+ if (convertedFrames is List) {
+ convertedFrames = frames.map(
+ (x) => convertDartToNative_Dictionary(x)).toList();
+ }
+ var convertedTiming = timing;
+ if (convertedTiming is Map) {
+ convertedTiming = convertDartToNative_Dictionary(convertedTiming);
+ }
+ return _animate(convertedFrames, convertedTiming);
+ }
+
+ @DomName('Element.animate')
+ @JSName('animate')
+ @Experimental() // untriaged
+ AnimationPlayer _animate(Object effect, [timing]) native;
+ /**
* Called by the DOM whenever an attribute on this has been changed.
*/
void attributeChanged(String name, String oldValue, String newValue) {}
@@ -12673,11 +12721,6 @@ abstract class Element extends Node implements GlobalEventHandlers, ParentNode,
@DocsEditable()
final String tagName;
- @DomName('Element.animate')
- @DocsEditable()
- @Experimental() // untriaged
- AnimationPlayer animate(Object effect, [Object timing]) native;
-
@DomName('Element.blur')
@DocsEditable()
void blur() native;
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('J')

Powered by Google App Engine
This is Rietveld 408576698