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

Side by Side Diff: appengine/config_service/ui/bower_components/polymer/lib/utils/render-status.html

Issue 2923973003: Added base template for config ui. (Closed)
Patch Set: Created 3 years, 6 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:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!--
2 @license
3 Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
9 -->
10 <link rel="import" href="boot.html">
11
12 <script>
13 (function() {
14
15 'use strict';
16
17 let scheduled = false;
18 let beforeRenderQueue = [];
19 let afterRenderQueue = [];
20
21 function schedule() {
22 scheduled = true;
23 // before next render
24 requestAnimationFrame(function() {
25 scheduled = false;
26 flushQueue(beforeRenderQueue);
27 // after the render
28 setTimeout(function() {
29 runQueue(afterRenderQueue);
30 });
31 });
32 }
33
34 function flushQueue(queue) {
35 while (queue.length) {
36 callMethod(queue.shift());
37 }
38 }
39
40 function runQueue(queue) {
41 for (let i=0, l=queue.length; i < l; i++) {
42 callMethod(queue.shift());
43 }
44 }
45
46 function callMethod(info) {
47 const context = info[0];
48 const callback = info[1];
49 const args = info[2];
50 try {
51 callback.apply(context, args);
52 } catch(e) {
53 setTimeout(() => {
54 throw e;
55 })
56 }
57 }
58
59 function flush() {
60 while (beforeRenderQueue.length || afterRenderQueue.length) {
61 flushQueue(beforeRenderQueue);
62 flushQueue(afterRenderQueue);
63 }
64 scheduled = false;
65 }
66
67 /**
68 * Module for scheduling flushable pre-render and post-render tasks.
69 *
70 * @namespace
71 * @memberof Polymer
72 * @summary Module for scheduling flushable pre-render and post-render tasks.
73 */
74 Polymer.RenderStatus = {
75
76 /**
77 * Enqueues a callback which will be run before the next render, at
78 * `requestAnimationFrame` timing.
79 *
80 * This method is useful for enqueuing work that requires DOM measurement,
81 * since measurement may not be reliable in custom element callbacks before
82 * the first render, as well as for batching measurement tasks in general.
83 *
84 * Tasks in this queue may be flushed by calling `Polymer.RenderStatus.flush ()`.
85 *
86 * @memberof Polymer.RenderStatus
87 * @param {*} context Context object the callback function will be bound to
88 * @param {function()} callback Callback function
89 * @param {Array} args An array of arguments to call the callback function w ith
90 */
91 beforeNextRender: function(context, callback, args) {
92 if (!scheduled) {
93 schedule();
94 }
95 beforeRenderQueue.push([context, callback, args]);
96 },
97
98 /**
99 * Enqueues a callback which will be run after the next render, equivalent
100 * to one task (`setTimeout`) after the next `requestAnimationFrame`.
101 *
102 * This method is useful for tuning the first-render performance of an
103 * element or application by deferring non-critical work until after the
104 * first paint. Typical non-render-critical work may include adding UI
105 * event listeners and aria attributes.
106 *
107 * @memberof Polymer.RenderStatus
108 * @param {*} context Context object the callback function will be bound to
109 * @param {function()} callback Callback function
110 * @param {Array} args An array of arguments to call the callback function w ith
111 */
112 afterNextRender: function(context, callback, args) {
113 if (!scheduled) {
114 schedule();
115 }
116 afterRenderQueue.push([context, callback, args]);
117 },
118
119 /**
120 * Flushes all `beforeNextRender` tasks, followed by all `afterNextRender`
121 * tasks.
122 *
123 * @memberof Polymer.RenderStatus
124 */
125 flush: flush
126
127 };
128
129 })();
130 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698