[Pkg-javascript-commits] [pdf.js] 56/174: Fix a regression, from PR 5356, that breaks all scrolling in PresentationMode
David Prévot
taffit at moszumanska.debian.org
Thu Nov 19 18:45:11 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 9fc8e1ea25285684ed5e38879b42b418dd2afb6a
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Tue Oct 13 12:47:07 2015 +0200
Fix a regression, from PR 5356, that breaks all scrolling in PresentationMode
*This regressed in PR 5356.*
Rather than just backing out the offending code, this patch restores scrolling in PresentationMode by making the `overflow: hidden;` check optional and letting the callers that need it (e.g. `PDFFindController`) opt-in to use it.
---
web/pdf_find_controller.js | 6 ++++--
web/ui_utils.js | 13 ++++++++-----
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/web/pdf_find_controller.js b/web/pdf_find_controller.js
index 605434f..afb563c 100644
--- a/web/pdf_find_controller.js
+++ b/web/pdf_find_controller.js
@@ -325,10 +325,12 @@ var PDFFindController = (function PDFFindControllerClosure() {
pageIndex, index, elements, beginIdx, endIdx) {
if (this.selected.matchIdx === index &&
this.selected.pageIdx === pageIndex) {
- scrollIntoView(elements[beginIdx], {
+ var spot = {
top: FIND_SCROLL_OFFSET_TOP,
left: FIND_SCROLL_OFFSET_LEFT
- });
+ };
+ scrollIntoView(elements[beginIdx], spot,
+ /* skipOverflowHiddenElements = */ true);
}
},
diff --git a/web/ui_utils.js b/web/ui_utils.js
index 20d1a18..d20d55f 100644
--- a/web/ui_utils.js
+++ b/web/ui_utils.js
@@ -113,11 +113,13 @@ function getOutputScale(ctx) {
/**
* Scrolls specified element into view of its parent.
- * element {Object} The element to be visible.
- * spot {Object} An object with optional top and left properties,
- * specifying the offset from the top left edge.
+ * @param {Object} element - The element to be visible.
+ * @param {Object} spot - An object with optional top and left properties,
+ * specifying the offset from the top left edge.
+ * @param {boolean} skipOverflowHiddenElements - Ignore elements that have
+ * the CSS rule `overflow: hidden;` set. The default is false.
*/
-function scrollIntoView(element, spot) {
+function scrollIntoView(element, spot, skipOverflowHiddenElements) {
// Assuming offsetParent is available (it's not available when viewer is in
// hidden iframe or object). We have to scroll: if the offsetParent is not set
// producing the error. See also animationStartedClosure.
@@ -126,10 +128,11 @@ function scrollIntoView(element, spot) {
console.error('offsetParent is not set -- cannot scroll');
return;
}
+ var checkOverflow = skipOverflowHiddenElements || false;
var offsetY = element.offsetTop + element.clientTop;
var offsetX = element.offsetLeft + element.clientLeft;
while (parent.clientHeight === parent.scrollHeight ||
- getComputedStyle(parent).overflow === 'hidden') {
+ (checkOverflow && getComputedStyle(parent).overflow === 'hidden')) {
if (parent.dataset._scaleY) {
offsetY /= parent.dataset._scaleY;
offsetX /= parent.dataset._scaleX;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list