Skip to content

Commit

Permalink
change after render method to Polymer.RenderStatus.afterNextRender
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Nov 5, 2015
1 parent c520907 commit 8949c04
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/lib/render-status.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,33 +49,34 @@
});
},

_afterFirstRenderQueue: [],
_afterNextRenderQueue: [],

_waitingAfterFirstRender: false,
_waitingNextRender: false,

afterFirstRender: function(element, fn, args) {
if (!this._waitingAfterFirstRender) {
this._waitingAfterFirstRender = true;
this.whenReady(this._flushAfterFirstRender);
afterNextRender: function(element, fn, args) {
if (!this._waitingNextRender) {
this._waitingNextRender = true;
this.whenReady(this._flushAfterNextRender);
}
this._afterFirstRenderQueue.push([element, fn, args]);
this._afterNextRenderQueue.push([element, fn, args]);
},

_flushAfterFirstRender: function() {
_flushAfterNextRender: function() {
// we want to defer flush until just after the next paint.
requestAnimationFrame(function() {
setTimeout(Polymer.RenderStatus.__flushAfterFirstRender);
setTimeout(Polymer.RenderStatus.__flushAfterNextRender);
});
},

__flushAfterFirstRender: function() {
__flushAfterNextRender: function() {
// called without context so force here.
var self = Polymer.RenderStatus;
self._waitingAfterFirstRender = false;
for (var i=0, h; i < self._afterFirstRenderQueue.length; i++) {
h = self._afterFirstRenderQueue[i];
self._waitingNextRender = false;
for (var i=0, h; i < self._afterNextRenderQueue.length; i++) {
h = self._afterNextRenderQueue[i];
h[1].apply(h[0], h[2] || Polymer.nar);
};
self._afterFirstRenderQueue = [];
self._afterNextRenderQueue = [];
}
};

Expand Down

0 comments on commit 8949c04

Please sign in to comment.