diff options
author | Mario Vavti <mario@mariovavti.com> | 2015-03-26 21:33:44 +0100 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2015-03-26 21:33:44 +0100 |
commit | c521a284860b6050bebcc554e28f860ebf2d2e23 (patch) | |
tree | e3b12f7214041ff951dc3fe1c633094ff6f1cf90 /view | |
parent | a5f410d587c350f26f9255e115260851551d2a15 (diff) | |
download | volse-hubzilla-c521a284860b6050bebcc554e28f860ebf2d2e23.tar.gz volse-hubzilla-c521a284860b6050bebcc554e28f860ebf2d2e23.tar.bz2 volse-hubzilla-c521a284860b6050bebcc554e28f860ebf2d2e23.zip |
do not move viewed content off the screen after collapsing a long post
Diffstat (limited to 'view')
-rw-r--r-- | view/js/main.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/view/js/main.js b/view/js/main.js index f6bc22e34..647d90358 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -616,12 +616,20 @@ function updateConvItems(mode,data) { function collapseHeight() { $(".wall-item-body, .contact-info").each(function() { - if($(this).height() > divmore_height + 10) { + var orgHeight = $(this).height(); + if(orgHeight > divmore_height + 10) { if(! $(this).hasClass('divmore')) { $(this).readmore({ collapsedHeight: divmore_height, moreLink: '<a href="#" class="divgrow-showmore">' + aStr.divgrowmore + '</a>', - lessLink: '<a href="#" class="divgrow-showmore">' + aStr.divgrowless + '</a>' + lessLink: '<a href="#" class="divgrow-showmore">' + aStr.divgrowless + '</a>', + beforeToggle: function(trigger, element, expanded) { + if(expanded) { + if((($(element).offset().top + divmore_height) - $(window).scrollTop()) < 65 ) { + $('html, body').animate( { scrollTop: $(window).scrollTop() - (orgHeight - divmore_height) }, {duration: 100 } ); + } + } + } }); $(this).addClass('divmore'); } |