Skip to content
This repository has been archived by the owner on Dec 22, 2018. It is now read-only.

Bugfix #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions docs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ PDFJS.workerSrc = './shared/pdf.worker.js';

// Render stuff
let NUM_PAGES = 0;
let renderedPages = {};
document.getElementById('content-wrapper').addEventListener('scroll', function (e) {
let visiblePageNum = Math.round(e.target.scrollTop / PAGE_HEIGHT) + 1;
let visiblePage = document.querySelector(`.page[data-page-number="${visiblePageNum}"][data-loaded="false"]`);

if (visiblePage) {
setTimeout(function () {
UI.renderPage(visiblePageNum, RENDER_OPTIONS);
});
// Prevent invoking UI.renderPage on the same page more than once.
if ( !renderedPages[visiblePageNum] ) {
renderedPages[visiblePageNum] = true;
setTimeout(function () {
UI.renderPage(visiblePageNum, RENDER_OPTIONS);
});
}
}
});

Expand Down
4 changes: 2 additions & 2 deletions scripts/web
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

./scripts/shared
cp -rf shared/ docs/shared/
cp -rf shared docs

server=./node_modules/.bin/webpack-dev-server
$server --inline --config ./webpack.web.js --content-base web/
$server --inline --config ./webpack.web.js --content-base docs/ $*