BUGFIX: user screen.width cause it will be more correct

BUGFIX: fix deprecation and regression in cloaking
PERF: cache progressWidth super aggresively to avoid reflows
This commit is contained in:
Sam 2014-06-02 10:30:16 +10:00
parent 13f4afe00f
commit 97eba92a2e
3 changed files with 10 additions and 9 deletions

View file

@ -23,6 +23,6 @@ export default {
// We consider high res a device with 1280 horizontal pixels. High DPI tablets like // We consider high res a device with 1280 horizontal pixels. High DPI tablets like
// iPads should report as 1024. // iPads should report as 1024.
caps.set('highRes', Modernizr.mq("only screen and (min-width: 1280px)")); caps.set('highRes', window.screen.width >= 1280);
} }
}; };

View file

@ -38,12 +38,13 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
} }
this._topicProgress = $topicProgress; this._topicProgress = $topicProgress;
// CAREFUL WITH THIS AXE // CAREFUL WITH THIS AXE
// offsetWidth will cause a reflow // offsetWidth will cause a reflow, this ensures it only happens once
this._progressWidth = $topicProgress[0].offsetWidth; // in future it may make sense to move this offscreen to to the measurement
Discourse.TopicView._progressWidth = Discourse.TopicView._progressWidth || $topicProgress[0].offsetWidth;
} }
// speeds up stuff, bypass jquery slowness and extra checks // speeds up stuff, bypass jquery slowness and extra checks
var totalWidth = this._progressWidth, var totalWidth = Discourse.TopicView._progressWidth,
progressWidth = this.get('controller.streamPercentage') * totalWidth; progressWidth = this.get('controller.streamPercentage') * totalWidth;
$topicProgress.find('.bg') $topicProgress.find('.bg')

View file

@ -286,7 +286,7 @@
cloak: function() { cloak: function() {
var self = this; var self = this;
if (this._containedView && this.get('state') === 'inDOM') { if (this._containedView && this._state === 'inDOM') {
var style = 'height: ' + this.$().height() + 'px;'; var style = 'height: ' + this.$().height() + 'px;';
this.set('style', style); this.set('style', style);
this.$().prop('style', style); this.$().prop('style', style);
@ -331,15 +331,15 @@
@method render @method render
*/ */
render: function(buffer) { render: function(buffer) {
var containedView = this._containedView; var containedView = this._containedView, self = this;
if (containedView && containedView.get('state') !== 'inDOM') { if (containedView && containedView._state !== 'inDOM') {
containedView.triggerRecursively('willInsertElement'); containedView.triggerRecursively('willInsertElement');
containedView.renderToBuffer(buffer); containedView.renderToBuffer(buffer);
containedView.transitionTo('inDOM'); containedView.transitionTo('inDOM');
Em.run.schedule('afterRender', function() { Em.run.schedule('afterRender', function() {
if(this._containedView) { if(self._containedView) {
this._containedView.triggerRecursively('didInsertElement'); self._containedView.triggerRecursively('didInsertElement');
} }
}); });
} }