Commit da6a7f9f authored by Julie Blanc's avatar Julie Blanc

rename and clean baseline script

parent 18aa3753
function snapBaseline(config){
const baselineDoc = config.baseline;
const strict = config.strict;
// 'true' = all the text elements snap strictly on the baseline (by default)
// 'false' = If the element have padding, it's not snap on the baseline
const showBaseline = config.showBaseline;
const elementBaseline = config.element;
......@@ -26,7 +23,6 @@ function snapBaseline(config){
/* baseline position + vertical Rythm of paragraphs */
const paragraph = 'p';
// verticalRythm(paragraph, '', '', baselineDoc, strict);
let baselinePosition = verticalRythm(paragraph, '', '', baselineDoc, strict);
let baselinePositionCSS = ':root{ --pagedjs-baseline-position : -' + baselinePosition + 'px; }'
addcss(baselinePositionCSS);
......@@ -51,7 +47,6 @@ function snapTextElement(elementSelector, baselinePosition, baselineDoc, strict)
// do calculation on each tag element
// verticalRythm(elementSelector, '', '', baselineDoc, configStrict);
let gapBaselineElem = verticalRythm(elementSelector, '', '', baselineDoc, configStrict);
let newgapBaselineElem = gapBaselineElem - baselinePosition;
......@@ -65,7 +60,6 @@ function snapTextElement(elementSelector, baselinePosition, baselineDoc, strict)
let allClasses = elem[i].classList;
let elemId = elem[i].id;
if(allClasses.length != 0 || elemId != ""){
// verticalRythm(elementSelector, allClasses, elemId, baselineDoc, configStrict);
let gapBaselineThisElem = verticalRythm(elementSelector, allClasses, elemId, baselineDoc, configStrict);
let newgapBaselineThisElem = gapBaselineThisElem - baselinePosition;
elem[i].style.top = newgapBaselineThisElem + "px";
......@@ -122,8 +116,6 @@ ________________________________________________________________________________
function verticalRythm(elem, elemClass, elemId, base, strict){
let baseline = base;
let configStrict = strict;
// let elemClass = elemClass;
// let elemId = elemId;
/* render element */
let element = document.createElement(elem);
......@@ -134,7 +126,7 @@ function verticalRythm(elem, elemClass, elemId, base, strict){
/* get styles of the font */
let styles = getStyle(element);
/* get font metrics */
/* get font metrics (unsing FontMetrics.js) */
const metrics = FontMetrics({
fontFamily: styles.fontFamily,
fontWeight: styles.fontWeight,
......@@ -235,10 +227,7 @@ function verticalRythm(elem, elemClass, elemId, base, strict){
elementSpecificId.style.marginBottom = newMarginBottom + "px";
}
/* distance between baseline font and baseline document */
let gapBaseline = ((computedLineHeight + baseline*ceilLineHeight)/2) - (metrics.top * -1 * styles.fontSize);
return gapBaseline;
......
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