-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Description
In the example with the prev/next page controls, if you click on the Next button too fast it'll render pages one on top of the other.
I've modified the example to use the continueCallback function but now when clicking on the button fast it sometimes renders the page upside down or with a wrong scale.
http://jsbin.com/pdfjs-prevnext-v2/1939/edit
var pdfDoc = null,
pageNum = 1,
scale = 2,
canvas = document.getElementById('the-canvas'),
ctx = canvas.getContext('2d'),
timestamp;
//
// Get page info from document, resize canvas accordingly, and render page
//
function renderPage(num) {
// Using promise to fetch the page
pdfDoc.getPage(num).then(function(page) {
var viewport = page.getViewport(scale);
canvas.height = viewport.height;
canvas.width = viewport.width;
// Render PDF page into canvas context
var pageTimestamp = new Date().getTime();
timestamp = pageTimestamp;
var renderContext = {
canvasContext: ctx,
viewport: viewport,
continueCallback: function(cont) {
if(timestamp != pageTimestamp) {
return;
}
cont();
}
};
page.render(renderContext);
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels