Fix shaking editor when typing

When using DPI scaling the scroll position could be set to a position
that
was not possible causing a scroll event to scroll back. This was causing
the editor to shake when editing. This PR fixes
this by rounding scrollTop and scrollLeft to a physical pixel instead of
rounding using Math.round

Co-authored-by: Antonio Scandurra <as-cii@github.com>
This commit is contained in:
Linus Eriksson
2018-02-28 09:24:18 +01:00
committed by Linus Eriksson
parent b42972fa84
commit de54e55878

View File

@@ -2811,7 +2811,7 @@ class TextEditorComponent {
setScrollTop (scrollTop) {
if (Number.isNaN(scrollTop) || scrollTop == null) return false
scrollTop = Math.round(Math.max(0, Math.min(this.getMaxScrollTop(), scrollTop)))
scrollTop = roundToPhysicalPixelBoundary(Math.max(0, Math.min(this.getMaxScrollTop(), scrollTop)))
if (scrollTop !== this.scrollTop) {
this.derivedDimensionsCache = {}
this.scrollTopPending = true
@@ -2842,7 +2842,7 @@ class TextEditorComponent {
setScrollLeft (scrollLeft) {
if (Number.isNaN(scrollLeft) || scrollLeft == null) return false
scrollLeft = Math.round(Math.max(0, Math.min(this.getMaxScrollLeft(), scrollLeft)))
scrollLeft = roundToPhysicalPixelBoundary(Math.max(0, Math.min(this.getMaxScrollLeft(), scrollLeft)))
if (scrollLeft !== this.scrollLeft) {
this.scrollLeftPending = true
this.scrollLeft = scrollLeft