1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-27 17:00:52 +01:00

Fix mobile browser hang issue when auto-reload by reducing DOM modification in forloop

This commit is contained in:
ben2613 2022-07-28 00:45:31 +01:00 committed by Fredrick Brennan
parent c128a37160
commit 72f38933c2

View File

@ -144,19 +144,26 @@ $(document).ready(function(){
url: document.location,
success: function(data) {
var loaded_posts = 0; // the number of new posts loaded in this update
var elementsToAppend = [];
var elementsToTriggerNewpostEvent = [];
$(data).find('div.post.reply').each(function() {
var id = $(this).attr('id');
if($('#' + id).length == 0) {
if (!new_posts) {
first_new_post = this;
}
$(this).insertAfter($('div.post:last').next()).after('<br class="clear">');
new_posts++;
loaded_posts++;
$(document).trigger('new_post', this);
recheck_activated();
elementsToAppend.push($(this));
elementsToAppend.push($('<br class="clear">'));
elementsToTriggerNewpostEvent.push(this);
}
});
$('div.post:last').next().after(elementsToAppend);
recheck_activated();
elementsToTriggerNewpostEvent.forEach(function(ele){
$(document).trigger('new_post', ele);
});
time_loaded = Date.now(); // interop with watch.js