From c521a284860b6050bebcc554e28f860ebf2d2e23 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 26 Mar 2015 21:33:44 +0100 Subject: do not move viewed content off the screen after collapsing a long post --- view/js/main.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'view') 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: '' + aStr.divgrowmore + '', - lessLink: '' + aStr.divgrowless + '' + lessLink: '' + aStr.divgrowless + '', + 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'); } -- cgit v1.2.3