do not move viewed content off the screen after collapsing a long post

This commit is contained in:
Mario Vavti 2015-03-26 21:33:44 +01:00
parent a5f410d587
commit c521a28486

View File

@ -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');
}