summaryrefslogtreecommitdiff
path: root/lib/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/scripts')
-rw-r--r--lib/scripts/linkwiz.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/scripts/linkwiz.js b/lib/scripts/linkwiz.js
index 01deb2234..ce4b6b101 100644
--- a/lib/scripts/linkwiz.js
+++ b/lib/scripts/linkwiz.js
@@ -119,6 +119,20 @@ linkwiz = {
if(obj){
linkwiz.deselect();
obj.className += ' selected';
+
+ // make sure the item is viewable in the scroll view
+ // FIXME check IE compatibility
+ if(obj.offsetTop > linkwiz.result.scrollTop + linkwiz.result.clientHeight){
+ linkwiz.result.scrollTop += obj.clientHeight;
+ }else if(obj.offsetTop - linkwiz.result.clientHeight < linkwiz.result.scrollTop){ // this works but isn't quite right, fixes welcome
+ linkwiz.result.scrollTop -= obj.clientHeight;
+ }
+ // now recheck - if still not in view, the user used the mouse to scroll
+ if( (obj.offsetTop > linkwiz.result.scrollTop + linkwiz.result.clientHeight) ||
+ (obj.offsetTop < linkwiz.result.scrollTop) ){
+ obj.scrollIntoView();
+ }
+
linkwiz.selected = num;
}
},