Merge branch 'bug/JAL-4375_annotation_not_redrawn_correctly_when_scrolling_left-right...
[jalview.git] / src / jalview / viewmodel / ViewportRanges.java
index 04db165..03d4172 100644 (file)
@@ -523,23 +523,31 @@ public class ViewportRanges extends ViewportProperties
    */
   public boolean scrollRight(boolean right)
   {
+    return scrollRight(right, 1);
+  }
+
+  public boolean scrollRight(boolean right, int jump)
+  {
     if (!right)
     {
       if (startRes < 1)
       {
         return false;
       }
-
-      setStartRes(startRes - 1);
+      int jumpto = Math.max(startRes - jump, 0);
+      setStartRes(jumpto);
     }
     else
     {
-      if (endRes >= getVisibleAlignmentWidth() - 1)
+      int vawidth = getVisibleAlignmentWidth();
+      if (endRes >= vawidth - 1)
       {
         return false;
       }
 
-      setStartRes(startRes + 1);
+      int jumpto = Math.min(startRes + jump,
+              vawidth - (endRes - startRes + 1));
+      setStartRes(jumpto);
     }
 
     return true;