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
// 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;
// CAREFUL WITH THIS AXE
// offsetWidth will cause a reflow
this._progressWidth = $topicProgress[0].offsetWidth;
// offsetWidth will cause a reflow, this ensures it only happens once
// 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
var totalWidth = this._progressWidth,
var totalWidth = Discourse.TopicView._progressWidth,
progressWidth = this.get('controller.streamPercentage') * totalWidth;
$topicProgress.find('.bg')

View File

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