OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview Simplified API wrapping native Web Animations with some sugar. | 6 * @fileoverview Simplified API wrapping native Web Animations with some sugar. |
7 * A compromise between the draft spec and Chrome's evolving support. This API | 7 * A compromise between the draft spec and Chrome's evolving support. This API |
8 * will be changed (or removed) as Chrome support evolves. | 8 * will be changed (or removed) as Chrome support evolves. |
9 */ | 9 */ |
10 cr.define('settings.animation', function() { | 10 cr.define('settings.animation', function() { |
(...skipping 30 matching lines...) Expand all Loading... |
41 this.finished = new Promise(function(resolve, reject) { | 41 this.finished = new Promise(function(resolve, reject) { |
42 // If we were implementing the full spec, we'd have to support | 42 // If we were implementing the full spec, we'd have to support |
43 // removing or resetting these listeners. | 43 // removing or resetting these listeners. |
44 self.animation_.addEventListener('finish', function(e) { | 44 self.animation_.addEventListener('finish', function(e) { |
45 resolve(); | 45 resolve(); |
46 // According to the spec, queue a task to fire the event after | 46 // According to the spec, queue a task to fire the event after |
47 // resolving the promise. | 47 // resolving the promise. |
48 self.queueDispatch_(e); | 48 self.queueDispatch_(e); |
49 }); | 49 }); |
50 self.animation_.addEventListener('cancel', function(e) { | 50 self.animation_.addEventListener('cancel', function(e) { |
| 51 // clang-format off |
51 reject(new | 52 reject(new |
52 /** | 53 /** |
53 * @see https://heycam.github.io/webidl/#es-DOMException-call | 54 * @see https://heycam.github.io/webidl/#es-DOMException-call |
54 * @type {function (new:DOMException, string, string)} | 55 * @type {function (new:DOMException, string, string)} |
55 */( | 56 */( |
56 DOMException | 57 DOMException |
57 )('', 'AbortError')); | 58 )('', 'AbortError')); |
| 59 // clang-format on |
58 self.queueDispatch_(e); | 60 self.queueDispatch_(e); |
59 }); | 61 }); |
60 }); | 62 }); |
61 } | 63 } |
62 | 64 |
63 Animation.prototype = { | 65 Animation.prototype = { |
64 __proto__: cr.EventTarget.prototype, | 66 __proto__: cr.EventTarget.prototype, |
65 | 67 |
66 finish: function() { | 68 finish: function() { |
67 assert(this.animation_); | 69 assert(this.animation_); |
(...skipping 15 matching lines...) Expand all Loading... |
83 this.animation_ = undefined; | 85 this.animation_ = undefined; |
84 }.bind(this)); | 86 }.bind(this)); |
85 }, | 87 }, |
86 }; | 88 }; |
87 | 89 |
88 return { | 90 return { |
89 Animation: Animation, | 91 Animation: Animation, |
90 Timing: Timing, | 92 Timing: Timing, |
91 }; | 93 }; |
92 }); | 94 }); |
OLD | NEW |