JAL-4375 Fix big sideways scroll from trackpad at beginning and end of visible alignment.
authorBen Soares <b.soares@dundee.ac.uk>
Wed, 31 Jan 2024 12:47:13 +0000 (12:47 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Wed, 31 Jan 2024 12:47:13 +0000 (12:47 +0000)
src/jalview/viewmodel/ViewportRanges.java

index f842736..03d4172 100644 (file)
@@ -530,21 +530,24 @@ public class ViewportRanges extends ViewportProperties
   {
     if (!right)
     {
-      if (startRes < jump)
+      if (startRes < 1)
       {
         return false;
       }
-
-      setStartRes(startRes - jump);
+      int jumpto = Math.max(startRes - jump, 0);
+      setStartRes(jumpto);
     }
     else
     {
-      if (endRes >= getVisibleAlignmentWidth() - jump)
+      int vawidth = getVisibleAlignmentWidth();
+      if (endRes >= vawidth - 1)
       {
         return false;
       }
 
-      setStartRes(startRes + jump);
+      int jumpto = Math.min(startRes + jump,
+              vawidth - (endRes - startRes + 1));
+      setStartRes(jumpto);
     }
 
     return true;