Closed thet closed 6 years ago
The print plugin is the answer: https://github.com/aFarkas/lazysizes/tree/gh-pages/plugins/print I'll integrate it, probably prepare a pull request and close this once I have it working and documented.
For the records: the issue might be not solved with the print plugin: https://github.com/aFarkas/lazysizes/issues/308 I'm experiencing similar problems for a client project. However, at least we have a partial solution.
maybe the print plugin needs some love; seems that it doesn't work if you don't do the scroll.
Not a smart way, but I was able to work around this problem by:
function sleep(waitSec, callbackFunc) {
var spanedSec = 0;
var waitFunc = function () {
spanedSec++;
if (spanedSec >= waitSec) {
if (callbackFunc) callbackFunc();
return;
}
clearTimeout(id);
id = setTimeout(waitFunc, 1000);
};
var id = setTimeout(waitFunc, 1000);
}
function unveilAndPrint() {
var ctr = 0;
document.querySelectorAll('img.lazyload').forEach(function(v, k, array) {
lazySizes.loader.unveil(v);
ctr++;
if (ctr === array.length) {
sleep(1, function() {
window.print();
ctr = 0;
});
}
});
}
when printing a page, there are no images because the plone.transformchain transform removes all images from the src-tag and for print no javascript is adding it back.
@hvelarde do you have a solution to this problem?