Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Simplify scrolling by grouping related actions in Swing thread

Author DaveJarvis <email>
Date 2021-04-06 16:37:03 GMT-0700
Commit 17da710167341c9c5b52239f5dd2e676ba2f31e2
Parent 69b4fcc
Delta 4 lines added, 18 lines removed, 14-line decrease
src/main/java/com/keenwrite/preview/HtmlPreview.java
}
- scrollTo( box );
+ if( box != null ) {
+ mView.scrollTo( createPoint( box ) );
+ getScrollPane().repaint();
+ }
} );
- }
-
- /**
- * Scrolls to the location specified by the {@link Box} that corresponds
- * to a point somewhere in the preview pane. If there is no caret, then
- * this will not change the scroll position. Changing the scroll position
- * to the top if the {@link Box} instance is {@code null} will result in
- * jumping around a lot and inconsistent synchronization issues.
- *
- * @param box The rectangular region containing the caret, or {@code null}
- * if the HTML does not have a caret.
- */
- private void scrollTo( final Box box ) {
- if( box != null ) {
- mView.scrollTo( createPoint( box ) );
- getScrollPane().repaint();
- }
}