Commit 8d895a33 authored by Kjetil Thuen's avatar Kjetil Thuen

Improved target accuracy

parent 78bbb9e2
...@@ -83,7 +83,7 @@ inScroll = false; ...@@ -83,7 +83,7 @@ inScroll = false;
var horizontalCenter = Math.floor(window.innerWidth/2), var horizontalCenter = Math.floor(window.innerWidth/2),
centerOfHeadline = 0, centerOfHeadline = 0,
focusedListElement = null, focusedListElement = null,
target_bottom = 0, target_top = 0,
scrollVal, scrollVal,
scrollListenersEnabled = false, scrollListenersEnabled = false,
scrollInProgress = false, scrollInProgress = false,
...@@ -126,8 +126,7 @@ inScroll = false; ...@@ -126,8 +126,7 @@ inScroll = false;
$('#target').animate({height: listElem.height(),'margin-top': marginDiff + 'px'}, 'fast'); $('#target').animate({height: listElem.height(),'margin-top': marginDiff + 'px'}, 'fast');
} }
//FIXME: Figure out where the 60pixels come from and make them dynamic $('html,body').animate({scrollTop: scrollVal}, 'fast');
$('body').animate({scrollTop: scrollVal + 60}, 'fast');
details = listElem.find("div.abstract").html(); details = listElem.find("div.abstract").html();
scrollInProgress = false; scrollInProgress = false;
...@@ -151,8 +150,8 @@ inScroll = false; ...@@ -151,8 +150,8 @@ inScroll = false;
listElem.addClass('selected'); listElem.addClass('selected');
focusedListElement = listElem; focusedListElement = listElem;
scrollVal = listElem.offset().top + listElem.height() - $('#studies_list').position().top; scrollVal = listElem.offset().top - $('#target').position().top;
console.log("Debouncing expand function"); console.log("Debouncing expand function at " + scrollVal);
debounce(show_expanded_info, 500, false)(); debounce(show_expanded_info, 500, false)();
} else { } else {
$('#expander').hide(); $('#expander').hide();
...@@ -168,16 +167,15 @@ inScroll = false; ...@@ -168,16 +167,15 @@ inScroll = false;
}; };
var initialize_list_peek = function() { var initialize_list_peek = function() {
target_bottom = $('#content').position().top; target_top = $('#content').position().top;
// $('#target').css({bottom: target_bottom}); $('#target').css({top: target_top});
horizontalCenter = Math.floor(window.innerWidth/2); horizontalCenter = Math.floor(window.innerWidth/2);
//FIXME: Figure out where the 60pixels come from and make them dynamic $('#expander').css({top: target_top + $('#target').height()});
$('#expander').css({top: target_bottom - 60});
centerOfHeadline = $('#target').offset().top - $(window).scrollTop() + ($('#target').height() / 2); centerOfHeadline = $('#target').offset().top - $(window).scrollTop() + ($('#target').height() / 2);
if (!handlersRegistered) { if (!handlersRegistered) {
register_event_handlers(); register_event_handlers();
} }
//set_selected_element(focusedListElement); set_selected_element(focusedListElement);
}; };
var register_event_handlers = function() { var register_event_handlers = function() {
......
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