myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3072] trunk/public/javascripts/controls.js: Fixe


From: noreply
Subject: [myexperiment-hackers] [3072] trunk/public/javascripts/controls.js: Fixed javascript scrolling issue
Date: Fri, 3 Aug 2012 14:16:08 +0000 (UTC)

Revision
3072
Author
fbacall
Date
2012-08-03 14:16:08 +0000 (Fri, 03 Aug 2012)

Log Message

Fixed _javascript_ scrolling issue

Modified Paths

Diff

Modified: trunk/public/_javascript_s/controls.js (3071 => 3072)


--- trunk/public/_javascript_s/controls.js	2012-08-02 16:02:57 UTC (rev 3071)
+++ trunk/public/_javascript_s/controls.js	2012-08-03 14:16:08 UTC (rev 3072)
@@ -208,16 +208,32 @@
     }
   },
 
+  // Added this fix: http://www.gilluminate.com/2009/01/20/scriptaculous-autocomplete-page-jump-using-arrow-keys/
+
   markPrevious: function() {
-    if(this.index > 0) this.index--;
-      else this.index = this.entryCount-1;
-    this.getEntry(this.index).scrollIntoView(true);
+   if(this.index > 0) {this.index--;}
+   else {
+    this.index = this.entryCount-1;
+    this.update.scrollTop = this.update.scrollHeight;
+   }
+   selection = this.getEntry(this.index);
+   selection_top = selection.offsetTop;
+   if(selection_top < this.update.scrollTop){
+    this.update.scrollTop = this.update.scrollTop-selection.offsetHeight;
+   }
   },
 
   markNext: function() {
-    if(this.index < this.entryCount-1) this.index++;
-      else this.index = 0;
-    this.getEntry(this.index).scrollIntoView(false);
+   if(this.index < this.entryCount-1) {this.index++;}
+   else {
+    this.index = 0;
+    this.update.scrollTop = 0;
+   }
+   selection = this.getEntry(this.index);
+   selection_bottom = selection.offsetTop+selection.offsetHeight;
+   if(selection_bottom > this.update.scrollTop+this.update.offsetHeight){
+    this.update.scrollTop = this.update.scrollTop+selection.offsetHeight;
+   }
   },
 
   getEntry: function(index) {
@@ -281,6 +297,7 @@
       }
 
       this.stopIndicator();
+      this.update.scrollTop = 0;
       this.index = 0;
 
       if(this.entryCount==1 && this.options.autoSelect) {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]