summaryrefslogtreecommitdiff
path: root/lib/scripts/linkwiz.js
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2009-08-14 12:53:44 +0200
committerAndreas Gohr <andi@splitbrain.org>2009-08-14 12:53:44 +0200
commit7fe97caa1ee1d0e4eb27139a9cb86aac0087b3a0 (patch)
treec0b8cc8a42102d0e5f705f419858e392506dc3f9 /lib/scripts/linkwiz.js
parent96ed8edc7d60f6963710ae9da1cf76b9738cabab (diff)
downloadrpg-7fe97caa1ee1d0e4eb27139a9cb86aac0087b3a0.tar.gz
rpg-7fe97caa1ee1d0e4eb27139a9cb86aac0087b3a0.tar.bz2
fix scrolling on keyboard select in LinkWizard
Ignore-this: 831a3252b5cb7c3f8658c377f60c0a95 darcs-hash:20090814105344-7ad00-6643571c3363ceb25d818246cf1425e3db6c8216.gz
Diffstat (limited to 'lib/scripts/linkwiz.js')
-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;
}
},