Commit afc0caf8 authored by Kjetil Thuen's avatar Kjetil Thuen

Better handling of overshooting.

Still needs quite a lot of tweaking to work smoothly
parent 6b5dd201
......@@ -111,6 +111,10 @@
};
var computeSightScopeOffset = function () {
return ((0) - (peekedList[0].getBoundingClientRect().height) + (settings.minTopDistance));
};
var computeTargetOffset = function () {
var listCoords = peekedList[0].getBoundingClientRect();
var targetCoord = listCoords.top < 0 ? settings.minTopDistance : listCoords.top + settings.minTopDistance;
return targetCoord;
......@@ -143,7 +147,13 @@
};
var findAndSelectElement = function () {
var newFocusedListElement = $(document.elementFromPoint(horizontalCenter, computeSightScopeOffset())).closest('li');
if (peekedList[0].getBoundingClientRect().top < settings.minTopDistance) {
$('#' + settings.sightScopeId).fadeIn();
} else {
$('#' + settings.sightScopeId).fadeOut();
}
var newFocusedListElement = $(document.elementFromPoint(horizontalCenter, computeTargetOffset())).closest('li');
if (newFocusedListElement.length > 0 && newFocusedListElement.attr('id') !== focusedListElement.attr('id')) {
setSelectedElement(newFocusedListElement);
}
......@@ -188,8 +198,8 @@
sightScopeId: "listSightScope",
itemInfoDivId: "selectedEntryItemInfo",
relativeTo: "list",
minTopDistance: "200",
minBottomDistance: "200",
minTopDistance: 200,
minBottomDistance: 200,
rememberLastSelected: false,
initialElement: undefined,
timeout: 100,
......@@ -215,7 +225,8 @@
'z-index': '-2',
padding: '0px',
position: 'fixed',
top: computeSightScopeOffset() + "px",
top: settings.minTopDistance + "px",
display: 'none',
}).insertAfter(peekedList);
if ($("#" + settings.itemInfoDivId).length === 0) {
......@@ -226,7 +237,7 @@
'z-index': 2,
display: 'none',
'max-height': '70%',
top: computeSightScopeOffset() + $('#' + settings.sightScopeId).height() + "px",
top: settings.minTopDistance + $('#' + settings.sightScopeId).height() + "px",
}).insertAfter(peekedList);
}
......
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