Use requestAnimationFrame instead of setTimeout

For better performance.
This commit is contained in:
JC Brand 2016-10-17 13:07:19 +02:00
parent acf3329ac2
commit 2d6d4df1f1
4 changed files with 11 additions and 9 deletions

View File

@ -137,7 +137,7 @@
this.$content = this.$el.find('.chat-content');
this.renderToolbar().renderAvatar();
converse.emit('chatBoxOpened', this);
window.setTimeout(utils.refreshWebkit, 50);
utils.refreshWebkit();
return this.showStatusMessage();
},

View File

@ -110,7 +110,7 @@
}
this.$content = this.$el.find('.chat-content');
converse.emit('chatBoxOpened', this);
window.setTimeout(utils.refreshWebkit, 50);
utils.refreshWebkit();
return this;
}
});

View File

@ -4,7 +4,7 @@
// Copyright (c) 2012-2016, Jan-Carel Brand <jc@opkode.com>
// Licensed under the Mozilla Public License (MPLv2)
//
/*global Backbone, define, window */
/*global Backbone, define */
/* This is a Converse.js plugin which add support for multi-user chat rooms, as
* specified in XEP-0045 Multi-user chat.
@ -284,7 +284,7 @@
info_configure: __('Configure this room'),
})));
this.renderChatArea();
window.setTimeout(converse.refreshWebkit, 50);
utils.refreshWebkit();
return this;
},

View File

@ -237,11 +237,13 @@
/* This works around a webkit bug. Refreshes the browser's viewport,
* otherwise chatboxes are not moved along when one is closed.
*/
if ($.browser.webkit) {
var conversejs = document.getElementById('conversejs');
conversejs.style.display = 'none';
var tmp = conversejs.offsetHeight; // jshint ignore:line
conversejs.style.display = 'block';
if ($.browser.webkit && window.requestAnimationFrame) {
window.requestAnimationFrame(function () {
var conversejs = document.getElementById('conversejs');
conversejs.style.display = 'none';
var tmp = conversejs.offsetHeight; // jshint ignore:line
conversejs.style.display = 'block';
});
}
},