Skip to content

Commit

Permalink
incorporate padding into nearViewport and aboveViewport calculations. f…
Browse files Browse the repository at this point in the history
…ixes #4
  • Loading branch information
dellsystem committed May 2, 2011
1 parent 132ab40 commit a36ab18
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
17 changes: 0 additions & 17 deletions README.md

This file was deleted.

10 changes: 5 additions & 5 deletions js/diva.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ THE SOFTWARE.
// Checks if a page is within the viewport
var nearViewport = function(pageID) {
var topOfPage = settings.heightAbovePages[pageID];
var bottomOfPage = topOfPage + settings.pages[pageID].h;
var bottomOfPage = topOfPage + settings.pages[pageID].h + settings.paddingPerPage;
var panelHeight = settings.panelHeight;
var topOfViewport = settings.scrollSoFar;
var bottomOfViewport = topOfViewport + panelHeight;
Expand Down Expand Up @@ -185,7 +185,7 @@ THE SOFTWARE.
var aboveViewport = function(pageID) {
// If the bottom of the page is above the top of viewport
// For when you want to keep looping but don't want to load a specific page
var bottomOfPage = settings.heightAbovePages[pageID] + settings.pages[pageID].h;
var bottomOfPage = settings.heightAbovePages[pageID] + settings.pages[pageID].h + settings.paddingPerPage;
var topOfViewport = settings.scrollSoFar;
if ( bottomOfPage < topOfViewport ) {
return true;
Expand All @@ -211,7 +211,7 @@ THE SOFTWARE.
var pageToConsider = settings.pageLoadedId + parseInt(direction, 10);
var middleOfViewport = settings.scrollSoFar + (settings.panelHeight / 2);
var changeCurrentPage = false;

// When scrolling up:
if ( direction < 0 ) {
// If the current pageTop is below the middle of the viewport
Expand All @@ -221,7 +221,7 @@ THE SOFTWARE.
}
} else if ( direction > 0) {
// When scrolling down:
// If the current pageTop is above the top and the current page isn't the last page
// If the previous pageTop is above the top and the current page isn't the last page
if ( settings.heightAbovePages[currentPage] < settings.scrollSoFar && pageToConsider < settings.pages.length ) {
changeCurrentPage = true;
}
Expand All @@ -234,7 +234,7 @@ THE SOFTWARE.
if ( changeCurrentPage ) {
// Set this to the current page
settings.pageLoadedId = pageToConsider;
// Change the text to reflect this - pageToConsider + 1 (becuase it's page number not ID)
// Change the text to reflect this - pageToConsider + 1 (because it's page number not ID)
$('#currentpage span').text(pageToConsider + 1);

// Now try to change the next page, given that we're not going to a specific page
Expand Down
2 changes: 1 addition & 1 deletion test.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
$('#documentpanel').diva({
// Optional
maxZoomLevel: 4,
paddingPerPage: 50,
paddingPerPage: 90,
zoomSlider: true,
gotoPage: true,
iipServerBaseUrl: "http://petrucci.musiclibs.net:9002/fcgi-bin/iipsrv.fcgi?FIF=/mnt/images/test/",
Expand Down

0 comments on commit a36ab18

Please sign in to comment.