Optimize delta callbacks (new feed)
This commit is contained in:
@@ -776,23 +776,26 @@ function updateFeed(bFirstChunk, bDiscrete, fCallback) {
|
||||
|
||||
function focusOnPost(oFocusPost) {
|
||||
if(oFocusPost) {
|
||||
var sElemId = '#'+oFocusPost.type+'-'+oFocusPost.id;
|
||||
var $Post = oSpot.tmp('$PostList').find(sElemId);
|
||||
var bGetToTop = (oSpot.tmp('$PostList').height() - (($Post.length > 0)?$Post.position().top:0) >= $(window).height());
|
||||
if($Post.length > 0 && (bGetToTop || self.tmp('out-of-data'))) {
|
||||
self.tmp('simple-bar').getScrollElement().scrollTop = Math.round(
|
||||
$Post.position().top +
|
||||
parseInt($Post.css('margin-top')) +
|
||||
(self.tmp('$Poster').is(':visible')?self.tmp('$Poster').outerHeight(true):0)
|
||||
);
|
||||
if(oFocusPost.type=='message' && (!oSpot.tmp(['markers', oFocusPost.id]) || !oSpot.tmp('map'))) setTimeout(function(){focusOnPost(oFocusPost);}, 100);
|
||||
else {
|
||||
var sElemId = '#'+oFocusPost.type+'-'+oFocusPost.id;
|
||||
var $Post = oSpot.tmp('$PostList').find(sElemId);
|
||||
var bGetToTop = (oSpot.tmp('$PostList').height() - (($Post.length > 0)?$Post.position().top:0) >= $(window).height());
|
||||
if($Post.length > 0 && (bGetToTop || self.tmp('out-of-data'))) {
|
||||
self.tmp('simple-bar').getScrollElement().scrollTop = Math.round(
|
||||
$Post.position().top +
|
||||
parseInt($Post.css('margin-top')) +
|
||||
(self.tmp('$Poster').is(':visible')?self.tmp('$Poster').outerHeight(true):0)
|
||||
);
|
||||
|
||||
if(oFocusPost.type=='media' || oFocusPost.type=='message') $Post.find('a.drill').click();
|
||||
if(oFocusPost.type=='media' || oFocusPost.type=='message') $Post.find('a.drill').click();
|
||||
}
|
||||
else if(!self.tmp('out-of-data')) updateFeed(false, false, function() {focusOnPost(oFocusPost);});
|
||||
else console.log('Missing element ID '+sElemId);
|
||||
|
||||
//Reset Hash
|
||||
oSpot.flushHash(['post', 'message']);
|
||||
}
|
||||
else if(!self.tmp('out-of-data')) updateFeed(false, false, function() {focusOnPost(oFocusPost);});
|
||||
else console.log('Missing element ID '+sElemId);
|
||||
|
||||
//Reset Hash
|
||||
oSpot.flushHash(['post', 'message']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user