aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2016-01-30 00:30:49 +0100
committerMario Vavti <mario@mariovavti.com>2016-01-30 00:30:49 +0100
commitd7abacb7b2737699d983862aa03628ee3d758545 (patch)
tree0b2ddab16886c298f3e1b662a94bd58dd73e8dd0 /view/js
parentc214692f661488df30eaf00ca85da94a5ecc1e14 (diff)
downloadvolse-hubzilla-d7abacb7b2737699d983862aa03628ee3d758545.tar.gz
volse-hubzilla-d7abacb7b2737699d983862aa03628ee3d758545.tar.bz2
volse-hubzilla-d7abacb7b2737699d983862aa03628ee3d758545.zip
it is not perfect but it still may ease the collapsing of items above the viewport a little...
Diffstat (limited to 'view/js')
-rw-r--r--view/js/main.js50
1 files changed, 47 insertions, 3 deletions
diff --git a/view/js/main.js b/view/js/main.js
index d670b704a..3906953f6 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -630,14 +630,29 @@ function updateConvItems(mode,data) {
} else {
collapseHeight();
}
+
}
+var contentHeightDiff = 0;
function collapseHeight() {
+ var origContentHeight = parseInt($("#region_2").height());
+ var cDiff = 0;
+ var i = 0;
$(".wall-item-content, .directory-collapse").each(function() {
- var orgHeight = $(this).outerHeight(true);
- if(orgHeight > divmore_height + 10) {
+ var orgHeight = parseInt($(this).height());
+ if(orgHeight > divmore_height) {
if(! $(this).hasClass('divmore')) {
+
+ // check if we will collapse some content above the visible content and compensate the diff later
+ if(($(this).offset().top + orgHeight - $(window).scrollTop()) < 50) {
+ diff = orgHeight - divmore_height;
+ //console.log('diff: ' + diff);
+
+ cDiff = cDiff + diff;
+ i++;
+ }
+
$(this).readmore({
speed: 0,
heightMargin: 50,
@@ -653,9 +668,38 @@ function collapseHeight() {
}
});
$(this).addClass('divmore');
+
}
}
});
+
+ var collapsedContentHeight = parseInt($("#region_2").height());
+ contentHeightDiff = origContentHeight - collapsedContentHeight;
+
+ if(i){
+
+ var position = $(window).scrollTop();
+
+ //console.log('cDiff: ' + cDiff);
+
+ //console.log('position: ' + position);
+
+ //console.log('origContentHeight: ' + origContentHeight);
+
+ //console.log('collapsedContentHeight: ' + collapsedContentHeight);
+
+ //console.log('contentHeightDiff: ' + contentHeightDiff);
+
+ var sval = position - cDiff + (i*3); // i*3 is possibly some border or margin/padding which might not be calculated correct
+
+ //console.log('sval: ' + sval);
+ console.log('collapsed above content count: ' + i);
+
+ $(window).scrollTop(sval);
+
+ //var nposition = $(document).scrollTop();
+ //console.log('nposition: ' + nposition);
+ }
}
function liveUpdate() {
@@ -708,7 +752,7 @@ function liveUpdate() {
$("#profile-jot-text-loading").spin(false);
if(update_mode === 'update') {
- $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight);
+ $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff);
}
in_progress = false;