Commit 7a8b2619 authored by Wei-Yin Chen (陳威尹)'s avatar Wei-Yin Chen (陳威尹) Committed by Commit Bot

Retain scroll position in distiller viewer after zooming

DOM distiller viewer was run in quirks mode, where the body is the
scrolling element. Later on, it was run in standard mode, where
the scrolling element became document.documentElement, and the
scroll positioning logic was broken.

Use document.scrollingElement instead to be more standard compliant.

See https://developer.mozilla.org/en-US/docs/Web/API/Document/scrollingElement

Bug: 874371
Change-Id: I1a0c04f4bc50ff66a9342e9fde8e0369b79cfef1
Reviewed-on: https://chromium-review.googlesource.com/1175681
Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583475}
parent fbf7df38
......@@ -204,8 +204,8 @@ var pincher = (function() {
function restoreCenter() {
var rect = focusElement.getBoundingClientRect();
var targetTop = focusPos * (rect.bottom - rect.top) + rect.top +
document.body.scrollTop - (initClientMid.y + shiftY);
document.body.scrollTop = targetTop;
document.scrollingElement.scrollTop - (initClientMid.y + shiftY);
document.scrollingElement.scrollTop = targetTop;
}
function endPinch() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment