Commit a952f401 authored by Kjetil Thuen's avatar Kjetil Thuen

Simplified scrolling code

parent 8d895a33
......@@ -84,7 +84,6 @@ inScroll = false;
centerOfHeadline = 0,
focusedListElement = null,
target_top = 0,
scrollVal,
scrollListenersEnabled = false,
scrollInProgress = false,
handlersRegistered = false;
......@@ -121,12 +120,20 @@ inScroll = false;
scrollListenersEnabled = false;
heightDiff = $('#target').height() - listElem.height();
marginDiff = parseInt($('#target').css('margin-top'), 0) + heightDiff;
if (heightDiff !== 0) {
marginDiff = parseInt($('#target').css('margin-top'), 0) + heightDiff;
$('#target').animate({height: listElem.height(),'margin-top': marginDiff + 'px'}, 'fast');
}
$('html,body').animate({scrollTop: scrollVal}, 'fast');
var tarTop = $('#target').position().top;
var listTop = listElem.offset().top;
var scrollVal = listTop - tarTop - marginDiff;
console.log("target top: " + tarTop);
console.log("list top: " + listTop);
console.log("Debouncing expand function at " + scrollVal);
$('body').animate({scrollTop: scrollVal}, 'fast');
details = listElem.find("div.abstract").html();
scrollInProgress = false;
......@@ -149,9 +156,6 @@ inScroll = false;
$('#studies_list li').removeClass("selected");
listElem.addClass('selected');
focusedListElement = listElem;
scrollVal = listElem.offset().top - $('#target').position().top;
console.log("Debouncing expand function at " + scrollVal);
debounce(show_expanded_info, 500, false)();
} else {
$('#expander').hide();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment