OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
6 | 6 |
7 @DocsEditable() | 7 @DocsEditable() |
8 $if DART2JS | 8 $if DART2JS |
9 $(ANNOTATIONS)@Native("Window,DOMWindow") | 9 $(ANNOTATIONS)@Native("Window,DOMWindow") |
10 $(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS { | 10 $(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 * request. This value only needs to be saved if you intend to call | 108 * request. This value only needs to be saved if you intend to call |
109 * [cancelAnimationFrame] so you can specify the particular animation to | 109 * [cancelAnimationFrame] so you can specify the particular animation to |
110 * cancel. | 110 * cancel. |
111 * | 111 * |
112 * Note: The supplied [callback] needs to call [requestAnimationFrame] again | 112 * Note: The supplied [callback] needs to call [requestAnimationFrame] again |
113 * for the animation to continue. | 113 * for the animation to continue. |
114 */ | 114 */ |
115 @DomName('Window.requestAnimationFrame') | 115 @DomName('Window.requestAnimationFrame') |
116 int requestAnimationFrame(FrameRequestCallback callback) { | 116 int requestAnimationFrame(FrameRequestCallback callback) { |
117 _ensureRequestAnimationFrame(); | 117 _ensureRequestAnimationFrame(); |
118 return _requestAnimationFrame(_wrapZone(callback)); | 118 return _requestAnimationFrame(_wrapZone/*<num, dynamic>*/(callback)); |
119 } | 119 } |
120 | 120 |
121 /** | 121 /** |
122 * Cancels an animation frame request. | 122 * Cancels an animation frame request. |
123 * | 123 * |
124 * ## Other resources | 124 * ## Other resources |
125 * | 125 * |
126 * * [Window.cancelAnimationFrame](https://developer.mozilla.org/en-US/docs/We
b/API/Window.cancelAnimationFrame) | 126 * * [Window.cancelAnimationFrame](https://developer.mozilla.org/en-US/docs/We
b/API/Window.cancelAnimationFrame) |
127 * from MDN. | 127 * from MDN. |
128 */ | 128 */ |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 334 |
335 class _BeforeUnloadEventStreamProvider implements | 335 class _BeforeUnloadEventStreamProvider implements |
336 EventStreamProvider<BeforeUnloadEvent> { | 336 EventStreamProvider<BeforeUnloadEvent> { |
337 final String _eventType; | 337 final String _eventType; |
338 | 338 |
339 const _BeforeUnloadEventStreamProvider(this._eventType); | 339 const _BeforeUnloadEventStreamProvider(this._eventType); |
340 | 340 |
341 Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) { | 341 Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) { |
342 var stream = new _EventStream(e, _eventType, useCapture); | 342 var stream = new _EventStream(e, _eventType, useCapture); |
343 $if DART2JS | 343 $if DART2JS |
344 var controller = new StreamController(sync: true); | 344 var controller = new StreamController<BeforeUnloadEvent>(sync: true); |
345 | 345 |
346 stream.listen((event) { | 346 stream.listen((event) { |
347 var wrapped = new _BeforeUnloadEvent(event); | 347 var wrapped = new _BeforeUnloadEvent(event); |
348 controller.add(wrapped); | 348 controller.add(wrapped); |
349 return wrapped.returnValue; | |
350 }); | 349 }); |
351 | 350 |
352 return controller.stream; | 351 return controller.stream; |
353 $else | 352 $else |
354 return stream; | 353 return stream; |
355 $endif | 354 $endif |
356 } | 355 } |
357 | 356 |
358 String getEventType(EventTarget target) { | 357 String getEventType(EventTarget target) { |
359 return _eventType; | 358 return _eventType; |
360 } | 359 } |
361 | 360 |
362 ElementStream<BeforeUnloadEvent> forElement(Element e, {bool useCapture: false
}) { | 361 ElementStream<BeforeUnloadEvent> forElement(Element e, {bool useCapture: false
}) { |
363 return new _ElementEventStreamImpl(e, _eventType, useCapture); | 362 return new _ElementEventStreamImpl(e, _eventType, useCapture); |
364 } | 363 } |
365 | 364 |
366 ElementStream<BeforeUnloadEvent> _forElementList(ElementList e, | 365 ElementStream<BeforeUnloadEvent> _forElementList(ElementList e, |
367 {bool useCapture: false}) { | 366 {bool useCapture: false}) { |
368 return new _ElementListEventStreamImpl(e, _eventType, useCapture); | 367 return new _ElementListEventStreamImpl(e, _eventType, useCapture); |
369 } | 368 } |
370 } | 369 } |
OLD | NEW |