mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-23 23:20:57 +01:00
Fix mobile browser hang issue when auto-reload by reducing DOM modification in forloop
This commit is contained in:
parent
c128a37160
commit
72f38933c2
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user