Commit d13b5bc6 authored by julien's avatar julien

tried some columns and float

parent 8fa65a24
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
function shift(el) {
// find the origin for each page
const page = el.closest(".pagedjs_page_content");
console.log(`page`);
console.log(page);
// find page center
const pageCenter = page.offsetWidth / 2;
console.log(`page center: ${pageCenter}`);
// location.left of each quote
// console.log(pageCenter);
const offset = el.offsetLeft
console.log(offset);
if (offset < pageCenter) {
el.classList.add('left-col');
}
else {
el.classList.add('right-col');
}
}
class SnapImages extends Paged.Handler {
constructor(chunker, polisher, caller) {
super(chunker, polisher, caller);
}
afterPageLayout(pageElement, page, breakToken){
let images = pageElement.getElementsByClassName("img-snap");
for(let i=0;i<images.length;i++){
let imgwidth = images[i].clientWidth;
let imgheight = images[i].clientHeight;
let varBaseline = getComputedStyle(images[i]).getPropertyValue('--font-lineHeight');
let baseline = parseInt(varBaseline.replace("px", ""));
let varHeightx = getComputedStyle(images[i]).getPropertyValue('--height-x');
let heightx = parseInt(varHeightx.replace("px", ""));
let ratio = Math.round((imgheight - heightx)/baseline);
images[i].style.height = "calc(var(--font-lineHeight)*" + ratio + " + var(--height-x))";
images[i].style.objectFit = "cover";
images[i].style.objectPosition = "center center";
}
}
}
Paged.registerHandlers(SnapImages);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment