Comments (10)
Just figured it out! UI.renderPage
is getting called multiple times on some pages and causes that strange effect. By tracking the page numbers that have been rendered in an array and checking if a page has been rendered before calling UI.renderPage
will remove the issue.
from pdf-annotate.js.
I encountered this too and am testing the "array" suggestion above. Seems to work.
// Render stuff
let NUM_PAGES = 0;
let renderedPages = [];
let okToRender = false;
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"]`);
console.log('pages', visiblePageNum, renderedPages.indexOf(visiblePageNum));
if (renderedPages.indexOf(visiblePageNum) == -1){
okToRender = true;
renderedPages.push(visiblePageNum);
} else {
okToRender = false;
}
if (visiblePage && okToRender) {
setTimeout(function () {
UI.renderPage(visiblePageNum, RENDER_OPTIONS);
});
}
});
from pdf-annotate.js.
Any luck with this @ghedwards?
from pdf-annotate.js.
Sort of.. I ended up building our own solution entirely using PDFJS, unfortunately I probably can't share it on here. Happy to have a chat about it privately if it's something you're looking for, send me an email or a Hangouts chat request.
from pdf-annotate.js.
Hi @mvanlonden , thanks for the hint! I couldn't solve it with an array - instead, I made sure scrolling doesn't trigger more than one event by adding a timeout:
var timeout;
document.getElementById('content-wrapper').addEventListener('scroll', function (e) {
clearTimeout(timeout);
timeout = setTimeout(function() {
var visiblePageNum = Math.round(e.target.scrollTop / PAGE_HEIGHT) + 1;
var visiblePage = document.querySelector('.page[data-page-number="' + visiblePageNum + '"][data-loaded="false"]');
if (visiblePage) {
setTimeout(function () {
UI.renderPage(visiblePageNum, RENDER_OPTIONS);
});
}
}, 50);
});
from pdf-annotate.js.
Thanks guys! @roypardi do you want to do a pull request. I tried your code and works.
from pdf-annotate.js.
I don't have a fork of this – I was just messing with a one-off download, so you will have to add it directly.
from pdf-annotate.js.
You also need to remember to clear the renderedPages array when you change scale or rotate as the pages won't be re-rendered.
from pdf-annotate.js.
Fixed in #57. But @patryksosinski 's point which is a good point is not catered yet!
from pdf-annotate.js.
Hi guys,
I have resolvedd this issues from my end. Please have a look below mentioned changes into my code (index.js) on Line number 140.
var NUM_PAGES = 0;
var timeout;
document.getElementById('content-wrapper').addEventListener('scroll', function(e) {
clearTimeout(timeout);
timeout = setTimeout(function() {
var visiblePageNum = Math.round(e.target.scrollTop / PAGE_HEIGHT) + 1;
var visiblePage = document.querySelector('.page[data-page-number="' + visiblePageNum + '"][data-loaded="false"]');
if (visiblePage) {
setTimeout(function() {
UI.renderPage(visiblePageNum, RENDER_OPTIONS);
});
}
}, 50);
});
from pdf-annotate.js.
Related Issues (20)
- Takes up lot of memory to render Large PDF docs where as it works smoothly in Vanilla PDF.JS HOT 3
- Example StoreAdapter
- Add highlighting support for mobile/touch HOT 3
- Page rendering is very slow HOT 22
- Is there more examples of how to use pdf-annotate.js? HOT 2
- Can I add a page in between a pdf file?
- While implementation of custom StoreAdapter getting documentId, pageNumber undefined.
- Angular 5/6 support?
- Click event not working on pdf's annotation in firefox HOT 2
- How to change pdf path to show it? HOT 1
- I updated pdf.js in my project and he work for me now HOT 7
- angular 6
- ./scripts/docs doesn't work
- How to use the toolbar of pdf-annotate.js in pdf.js? HOT 2
- PDF Annotate not work more in iOS 12 HOT 2
- Can I use mysql DB instead of localStorage API? HOT 2
- How can I add more annotation options?
- Npm start occurs an error HOT 1
- is this under active development? HOT 1
- Is annotation saved on server?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdf-annotate.js.