since we preload images now we also can collapse and calculate posts above the viewport

This commit is contained in:
Mario Vavti 2016-02-16 14:42:13 +01:00
parent c5827c8b4f
commit 3be6ef6bfc

View File

@ -638,12 +638,24 @@ function updateConvItems(mode,data) {
function collapseHeight() {
var origContentHeight = parseInt($("#region_2").height());
var cDiff = 0;
var i = 0;
var position = $(window).scrollTop();
$(".wall-item-content, .directory-collapse").each(function() {
var orgHeight = parseInt($(this).css('height'));
if(orgHeight > divmore_height) {
if(! $(this).hasClass('divmore')) {
var trigger = $(window).scrollTop() < $(this).offset().top ? true : false;
//var trigger = $(window).scrollTop() < $(this).offset().top ? true : false;
var trigger = true;
// check if we will collapse some content above the visible content and compensate the diff later
if($(window).scrollTop() > $(this).offset().top) {
diff = orgHeight - divmore_height;
cDiff = cDiff + diff;
i++;
}
if(trigger) {
$(this).readmore({
@ -670,6 +682,12 @@ function collapseHeight() {
contentHeightDiff = origContentHeight - collapsedContentHeight;
console.log('collapseHeight() - contentHeightDiff: ' + contentHeightDiff + 'px');
if(i){
var sval = position - cDiff + $(".divgrow-showmore").height();
console.log('collapsed above content count: ' + i);
$(window).scrollTop(sval);
}
}
@ -724,34 +742,34 @@ function liveUpdate() {
console.log('LOADING images...');
$('.wall-item-body, .wall-photo-item',data).imagesLoaded( function() {
var iready = new Date();
console.log('IMAGES ready in: ' + (iready - dready)/1000 + ' seconds.');
var iready = new Date();
console.log('IMAGES ready in: ' + (iready - dready)/1000 + ' seconds.');
page_load = false;
scroll_next = false;
updateConvItems(update_mode,data);
$("#page-spinner").spin(false);
$("#profile-jot-text-loading").spin(false);
page_load = false;
scroll_next = false;
updateConvItems(update_mode,data);
$("#page-spinner").spin(false);
$("#profile-jot-text-loading").spin(false);
if(update_mode === 'update') {
$(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff);
}
if(update_mode === 'update') {
$(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff);
}
in_progress = false;
in_progress = false;
// FIXME - the following lines were added so that almost
// immediately after we update the posts on the page, we
// re-check and update the notification counts.
// As it turns out this causes a bit of an inefficiency
// as we're pinging twice for every update, once before
// and once after. A btter way to do this is to rewrite
// NavUpdate and perhaps LiveUpdate so that we check for
// post updates first and only call the notification ping
// once.
// FIXME - the following lines were added so that almost
// immediately after we update the posts on the page, we
// re-check and update the notification counts.
// As it turns out this causes a bit of an inefficiency
// as we're pinging twice for every update, once before
// and once after. A btter way to do this is to rewrite
// NavUpdate and perhaps LiveUpdate so that we check for
// post updates first and only call the notification ping
// once.
updateCountsOnly = true;
if(timer) clearTimeout(timer);
timer = setTimeout(NavUpdate,10);
updateCountsOnly = true;
if(timer) clearTimeout(timer);
timer = setTimeout(NavUpdate,10);
});