File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -540,6 +540,18 @@ export class DocView {
540540 Math . max ( Math . min ( target . xMargin , offsetWidth ) , - offsetWidth ) ,
541541 Math . max ( Math . min ( target . yMargin , offsetHeight ) , - offsetHeight ) ,
542542 this . view . textDirection == Direction . LTR )
543+ // On mobile browsers, the visual viewport may be smaller than the
544+ // actual reported viewport, causing scrollRectIntoView to fail to
545+ // scroll properly. Unfortunately, this visual viewport cannot be
546+ // updated directly, and scrollIntoView is the only way a script
547+ // can affect it. So this tries to kludge around the problem by
548+ // calling scrollIntoView on the scroll target's line.
549+ if ( window . visualViewport && window . innerHeight - window . visualViewport . height > 1 &&
550+ ( rect . top > window . pageYOffset + window . visualViewport . offsetTop + window . visualViewport . height ||
551+ rect . bottom < window . pageYOffset + window . visualViewport . offsetTop ) ) {
552+ let line = this . view . docView . lineAt ( range . head , 1 )
553+ if ( line ) line . dom . scrollIntoView ( { block : "nearest" } )
554+ }
543555 }
544556
545557 lineHasWidget ( pos : number ) {
You can’t perform that action at this time.
0 commit comments