From 8949c0470b39a7cf0e17f9df03fd4dce0cd7bf78 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Thu, 5 Nov 2015 12:27:37 -0800 Subject: [PATCH] change after render method to `Polymer.RenderStatus.afterNextRender` --- src/lib/render-status.html | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/lib/render-status.html b/src/lib/render-status.html index 01fed70155..eb687cf377 100644 --- a/src/lib/render-status.html +++ b/src/lib/render-status.html @@ -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 = []; } };