Commit eac26a62 authored by julien's avatar julien
Browse files

cleaner code

parent 731a9e83
import Handler from "../handler";
import csstree from "css-tree";
// import { registerHandlers } from "../../utils/handlers";
// import { toMatchImageSnapshot } from "jest-image-snapshot";
// import { DefaultSerializer } from "v8";
// import { identifier } from "@babel/types";
// - check if top, left, right or bottom properties are used and stock values in var.
// - remove the position fixed on the element and set absolute
// - for each new page, add the element as the first child of .pagedjs_page
// set css for this element as position: absolute and set the positionning css top/left/right/bottom
class PositionFixed extends Handler {
constructor(chunker, polisher, caller) {
......@@ -17,9 +7,6 @@ class PositionFixed extends Handler {
this.styleSheet = polisher.styleSheet;
this.fixedElementsSelector = [];
this.fixedElements = [];
// this.selectors = {};
// this.clone = {};
// this.identifier = [];
}
onDeclaration(declaration, dItem, dList, rule) {
......@@ -34,25 +21,18 @@ class PositionFixed extends Handler {
this.fixedElementsSelector.forEach(fixedEl => {
fragment.querySelectorAll(`${fixedEl}`).forEach(el => {
el.style.setProperty("position", "absolute");
el.setAttribute("fixed-clone", "");
this.fixedElements.push(el);
console.log(this.fixedElements);
el.remove()
el.remove();
});
});
}
// after page layout add the element and fix it on the page.
afterPageLayout(pageElement, page, breakToken) {
// pageElement.querySelectorAll(`[fixed-clone]`).forEach(source => source.remove());
this.fixedElements.forEach(el => {
const clone = el.cloneNode(true);
page.element.querySelector(".pagedjs_pagebox").insertAdjacentElement("afterbegin", clone);
})
pageElement.querySelector(".pagedjs_pagebox").insertAdjacentElement("afterbegin", clone);
});
}
}
......
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