2017-02-15 20:51:21 -08:00
|
|
|
<!--
|
|
|
|
|
@license
|
|
|
|
|
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
|
|
|
|
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
|
|
|
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
|
|
|
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
|
|
|
Code distributed by Google as part of the polymer project is also
|
|
|
|
|
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
|
|
|
-->
|
|
|
|
|
<link rel="import" href="boot.html">
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
(function() {
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
let scheduled = false;
|
|
|
|
|
let beforeRenderQueue = [];
|
|
|
|
|
let afterRenderQueue = [];
|
|
|
|
|
|
|
|
|
|
function schedule() {
|
|
|
|
|
scheduled = true;
|
|
|
|
|
// before next render
|
|
|
|
|
requestAnimationFrame(function() {
|
|
|
|
|
scheduled = false;
|
|
|
|
|
flushQueue(beforeRenderQueue);
|
|
|
|
|
// after the render
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
flushQueue(afterRenderQueue);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function flushQueue(queue) {
|
2017-02-21 12:03:25 -08:00
|
|
|
for (let i=0, q, context, callback, args; i<queue.length; i++) {
|
2017-02-15 20:51:21 -08:00
|
|
|
try {
|
2017-02-21 12:03:25 -08:00
|
|
|
q = queue[i];
|
|
|
|
|
context = q[0];
|
|
|
|
|
callback = q[1];
|
|
|
|
|
args = q[2];
|
|
|
|
|
callback.apply(context, args);
|
2017-02-15 20:51:21 -08:00
|
|
|
} catch(e) {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
throw e;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
queue.length = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-24 19:43:23 -08:00
|
|
|
function flush() {
|
|
|
|
|
flushQueue(beforeRenderQueue);
|
|
|
|
|
flushQueue(afterRenderQueue);
|
|
|
|
|
if (beforeRenderQueue.length || afterRenderQueue.length) {
|
|
|
|
|
flush();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-15 21:13:46 -08:00
|
|
|
Polymer.RenderStatus = {
|
2017-02-15 20:51:21 -08:00
|
|
|
|
2017-02-21 12:03:25 -08:00
|
|
|
beforeNextRender: function(context, callback, args) {
|
2017-02-15 20:51:21 -08:00
|
|
|
if (!scheduled) {
|
|
|
|
|
schedule();
|
|
|
|
|
}
|
2017-02-21 12:08:48 -08:00
|
|
|
beforeRenderQueue.push([context, callback, args]);
|
2017-02-15 20:51:21 -08:00
|
|
|
},
|
|
|
|
|
|
2017-02-21 12:03:25 -08:00
|
|
|
afterNextRender: function(context, callback, args) {
|
2017-02-15 20:51:21 -08:00
|
|
|
if (!scheduled) {
|
|
|
|
|
schedule();
|
|
|
|
|
}
|
2017-02-21 12:08:48 -08:00
|
|
|
afterRenderQueue.push([context, callback, args]);
|
2017-02-24 19:43:23 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
flush: flush
|
2017-02-15 20:51:21 -08:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
</script>
|