since we preload images now we also can collapse and calculate posts above the viewport
This commit is contained in:
parent
c5827c8b4f
commit
3be6ef6bfc
@ -638,12 +638,24 @@ function updateConvItems(mode,data) {
|
|||||||
|
|
||||||
function collapseHeight() {
|
function collapseHeight() {
|
||||||
var origContentHeight = parseInt($("#region_2").height());
|
var origContentHeight = parseInt($("#region_2").height());
|
||||||
|
var cDiff = 0;
|
||||||
|
var i = 0;
|
||||||
|
var position = $(window).scrollTop();
|
||||||
|
|
||||||
$(".wall-item-content, .directory-collapse").each(function() {
|
$(".wall-item-content, .directory-collapse").each(function() {
|
||||||
var orgHeight = parseInt($(this).css('height'));
|
var orgHeight = parseInt($(this).css('height'));
|
||||||
if(orgHeight > divmore_height) {
|
if(orgHeight > divmore_height) {
|
||||||
if(! $(this).hasClass('divmore')) {
|
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) {
|
if(trigger) {
|
||||||
$(this).readmore({
|
$(this).readmore({
|
||||||
@ -670,6 +682,12 @@ function collapseHeight() {
|
|||||||
contentHeightDiff = origContentHeight - collapsedContentHeight;
|
contentHeightDiff = origContentHeight - collapsedContentHeight;
|
||||||
console.log('collapseHeight() - contentHeightDiff: ' + contentHeightDiff + 'px');
|
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...');
|
console.log('LOADING images...');
|
||||||
|
|
||||||
$('.wall-item-body, .wall-photo-item',data).imagesLoaded( function() {
|
$('.wall-item-body, .wall-photo-item',data).imagesLoaded( function() {
|
||||||
var iready = new Date();
|
var iready = new Date();
|
||||||
console.log('IMAGES ready in: ' + (iready - dready)/1000 + ' seconds.');
|
console.log('IMAGES ready in: ' + (iready - dready)/1000 + ' seconds.');
|
||||||
|
|
||||||
page_load = false;
|
page_load = false;
|
||||||
scroll_next = false;
|
scroll_next = false;
|
||||||
updateConvItems(update_mode,data);
|
updateConvItems(update_mode,data);
|
||||||
$("#page-spinner").spin(false);
|
$("#page-spinner").spin(false);
|
||||||
$("#profile-jot-text-loading").spin(false);
|
$("#profile-jot-text-loading").spin(false);
|
||||||
|
|
||||||
if(update_mode === 'update') {
|
if(update_mode === 'update') {
|
||||||
$(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff);
|
$(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff);
|
||||||
}
|
}
|
||||||
|
|
||||||
in_progress = false;
|
in_progress = false;
|
||||||
|
|
||||||
// FIXME - the following lines were added so that almost
|
// FIXME - the following lines were added so that almost
|
||||||
// immediately after we update the posts on the page, we
|
// immediately after we update the posts on the page, we
|
||||||
// re-check and update the notification counts.
|
// re-check and update the notification counts.
|
||||||
// As it turns out this causes a bit of an inefficiency
|
// As it turns out this causes a bit of an inefficiency
|
||||||
// as we're pinging twice for every update, once before
|
// as we're pinging twice for every update, once before
|
||||||
// and once after. A btter way to do this is to rewrite
|
// and once after. A btter way to do this is to rewrite
|
||||||
// NavUpdate and perhaps LiveUpdate so that we check for
|
// NavUpdate and perhaps LiveUpdate so that we check for
|
||||||
// post updates first and only call the notification ping
|
// post updates first and only call the notification ping
|
||||||
// once.
|
// once.
|
||||||
|
|
||||||
updateCountsOnly = true;
|
updateCountsOnly = true;
|
||||||
if(timer) clearTimeout(timer);
|
if(timer) clearTimeout(timer);
|
||||||
timer = setTimeout(NavUpdate,10);
|
timer = setTimeout(NavUpdate,10);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user