Merge pull request #2023 from yurydelendik/scrollIntoView

Replaces scrollIntoView
This commit is contained in:
Brendan Dahl 2012-08-27 12:14:02 -07:00
commit 57866c514b
2 changed files with 21 additions and 27 deletions

View File

@ -29,29 +29,17 @@ select {
#viewerContainer:-webkit-full-screen { #viewerContainer:-webkit-full-screen {
top: 0px; top: 0px;
padding-top: 6px; border-top: 5px solid transparent;
padding-bottom: 24px;
background-color: #404040; background-color: #404040;
background-image: url(images/texture.png); background-image: url(images/texture.png);
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow: auto;
}
:-webkit-full-screen #viewer {
margin: 0pt;
padding: 0pt;
height: 100%;
width: 100%;
overflow: hidden; overflow: hidden;
} }
:-webkit-full-screen .page {
margin: 0px auto;
margin-bottom: 10px;
}
#viewerContainer:-moz-full-screen { #viewerContainer:-moz-full-screen {
top: 0px;
border-top: 5px solid transparent;
background-color: #404040; background-color: #404040;
background-image: url(images/texture.png); background-image: url(images/texture.png);
width: 100%; width: 100%;
@ -59,6 +47,10 @@ select {
overflow: hidden; overflow: hidden;
} }
:-webkit-full-screen .page:last-child {
margin-bottom: 40px;
}
:-moz-full-screen .page:last-child { :-moz-full-screen .page:last-child {
margin-bottom: 40px; margin-bottom: 40px;
} }

View File

@ -33,6 +33,17 @@ function getFileName(url) {
return url.substring(url.lastIndexOf('/', end) + 1, end); return url.substring(url.lastIndexOf('/', end) + 1, end);
} }
function scrollIntoView(element, spot) {
var parent = element.offsetParent, offsetY = element.offsetTop;
while (parent.clientHeight == parent.scrollHeight) {
offsetY += parent.offsetTop;
parent = parent.offsetParent;
}
if (spot)
offsetY += spot.top;
parent.scrollTop = offsetY;
}
var Cache = function cacheCache(size) { var Cache = function cacheCache(size) {
var data = []; var data = [];
this.push = function cachePush(view) { this.push = function cachePush(view) {
@ -1315,7 +1326,7 @@ var PageView = function pageView(container, pdfPage, id, scale,
this.scrollIntoView = function pageViewScrollIntoView(dest) { this.scrollIntoView = function pageViewScrollIntoView(dest) {
if (!dest) { if (!dest) {
div.scrollIntoView(true); scrollIntoView(div);
return; return;
} }
@ -1374,16 +1385,7 @@ var PageView = function pageView(container, pdfPage, id, scale,
var width = Math.abs(boundingRect[0][0] - boundingRect[1][0]); var width = Math.abs(boundingRect[0][0] - boundingRect[1][0]);
var height = Math.abs(boundingRect[0][1] - boundingRect[1][1]); var height = Math.abs(boundingRect[0][1] - boundingRect[1][1]);
// using temporary div to scroll it into view scrollIntoView(div, {left: x, top: y, width: width, height: height});
var tempDiv = document.createElement('div');
tempDiv.style.position = 'absolute';
tempDiv.style.left = Math.floor(x) + 'px';
tempDiv.style.top = Math.floor(y) + 'px';
tempDiv.style.width = Math.ceil(width) + 'px';
tempDiv.style.height = Math.ceil(height) + 'px';
div.appendChild(tempDiv);
tempDiv.scrollIntoView(true);
div.removeChild(tempDiv);
}, 0); }, 0);
}; };
@ -2084,7 +2086,7 @@ window.addEventListener('pagechange', function pagechange(evt) {
var last = numVisibleThumbs > 1 ? var last = numVisibleThumbs > 1 ?
visibleThumbs.last.id : first; visibleThumbs.last.id : first;
if (page <= first || page >= last) if (page <= first || page >= last)
thumbnail.scrollIntoView(); scrollIntoView(thumbnail);
} }
} }