-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Added more than option for page breaks #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added more than option for page breaks #138
Conversation
eKoopmans
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @WilcoBreedt, thank you very much! I like the idea of specifying before/after/avoid, though I'm thinking of adopting the standard CSS as a guideline. I also like your use of margins as a more flexible solution.
There are currently 4 different pagebreak PRs, I'm looking into combining them into one. Thanks again!
| Array.prototype.forEach.call(pageBreakAvoid, function pageBreak_loop(el) { | ||
| el.style.display = 'block'; | ||
| var clientRect = el.getBoundingClientRect(); | ||
| var margin = toPx(this.opt.margin[0], this.prop.pageSize.k); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since pxPageHeight uses pageSize.inner (the "inner" size), none of the other calculations should need to account for margin.
| el.style.display = 'block'; | ||
| var clientRect = el.getBoundingClientRect(); | ||
| var margin = toPx(this.opt.margin[0], this.prop.pageSize.k); | ||
| if ((((clientRect.bottom + margin) / this.prop.container.offsetHeight) * pxPageHeight) > pxPageHeight) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the offsetHeight is for here...
| Array.prototype.forEach.call(pageBreaksAfter, function pageBreak_loop(el) { | ||
| el.style.display = 'block'; | ||
| var clientRect = el.getBoundingClientRect(); | ||
| el.style.marginBottom = pxPageHeight - (clientRect.top - margin) % pxPageHeight + 'px'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should subtract clientRect.bottom, not top.
| el.style.display = 'block'; | ||
| var clientRect = el.getBoundingClientRect(); | ||
| el.style.height = pxPageHeight - (clientRect.top % pxPageHeight) + 'px'; | ||
| el.style.marginBottom = pxPageHeight - (clientRect.top - margin) % pxPageHeight + 'px'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise, clientRect.bottom.
|
@eKoopmans , cool man, no probs ! Just hope I could have been of some help xD |
|
Hi, closing as these features were combined into #153. Thanks again for the contribution, I'll add you as a contributor on the readme! |
No description provided.