@@ -243,10 +243,10 @@ export default (
243
243
// https://www.quirksmode.org/blog/archives/2016/02/chrome_change_b.html
244
244
const viewportWidth = window . visualViewport
245
245
? window . visualViewport . width
246
- : viewport . clientWidth
246
+ : Math . min ( viewport . clientWidth , window . innerWidth )
247
247
const viewportHeight = window . visualViewport
248
248
? window . visualViewport . height
249
- : viewport . clientHeight
249
+ : Math . min ( viewport . clientHeight , window . innerHeight )
250
250
const viewportX = window . scrollX || window . pageXOffset
251
251
const viewportY = window . scrollY || window . pageYOffset
252
252
@@ -316,7 +316,7 @@ export default (
316
316
targetBlock = targetRect . top + targetRect . height / 2
317
317
}
318
318
if ( viewport === frame ) {
319
- blockScroll = viewportY + targetBlock - frame . clientHeight / 2
319
+ blockScroll = viewportY + targetBlock - viewportHeight / 2
320
320
} else {
321
321
// prevent negative scrollTop values
322
322
const offset =
@@ -335,7 +335,7 @@ export default (
335
335
targetBlock = targetRect . bottom
336
336
}
337
337
if ( viewport === frame ) {
338
- blockScroll = viewportY + targetBlock - frame . clientHeight
338
+ blockScroll = viewportY + targetBlock - viewportHeight
339
339
} else {
340
340
// prevent negative scrollTop values
341
341
const offset =
@@ -399,7 +399,7 @@ export default (
399
399
targetInline = targetRect . left + targetRect . width / 2
400
400
}
401
401
if ( viewport === frame ) {
402
- inlineScroll = viewportX + targetInline - frame . clientWidth / 2
402
+ inlineScroll = viewportX + targetInline - viewportWidth / 2
403
403
} else {
404
404
// prevent negative scrollLeft values
405
405
const offset =
@@ -418,7 +418,7 @@ export default (
418
418
targetInline = targetRect . right
419
419
}
420
420
if ( viewport === frame ) {
421
- inlineScroll = viewportX + targetInline - frame . clientWidth
421
+ inlineScroll = viewportX + targetInline - viewportWidth
422
422
} else {
423
423
// prevent negative scrollLeft values
424
424
const offset =
0 commit comments