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() { 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);
}
} }