aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/main.js
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2016-02-16 14:42:13 +0100
committerMario Vavti <mario@mariovavti.com>2016-02-16 14:42:13 +0100
commit3be6ef6bfcf662616b37da85fbeb2a7a08a1bd4e (patch)
tree40f7e69c8541e709e514f63a6bf59a43adb8af07 /view/js/main.js
parentc5827c8b4f0079e6916a86e8cb51d7b4b2be13b2 (diff)
downloadvolse-hubzilla-3be6ef6bfcf662616b37da85fbeb2a7a08a1bd4e.tar.gz
volse-hubzilla-3be6ef6bfcf662616b37da85fbeb2a7a08a1bd4e.tar.bz2
volse-hubzilla-3be6ef6bfcf662616b37da85fbeb2a7a08a1bd4e.zip
since we preload images now we also can collapse and calculate posts above the viewport
Diffstat (limited to 'view/js/main.js')
-rw-r--r--view/js/main.js68
1 files changed, 43 insertions, 25 deletions
diff --git a/view/js/main.js b/view/js/main.js
index cf367ec87..f9f88aec6 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -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.
-
- updateCountsOnly = true;
- if(timer) clearTimeout(timer);
- timer = setTimeout(NavUpdate,10);
+ // 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);
});