Commit 3a494689 authored by Julie Blanc's avatar Julie Blanc

add parameters for the script

parent 1612bd59
......@@ -14,7 +14,6 @@ function snapBaseline(config){
/* Visibility of the baseline */
let showBaselineCSS = elementBaseline + `{
--baseline-position: 0px;
background: linear-gradient( transparent 0%, transparent calc(var(--baseline) - 1px), #999 calc(var(--baseline) - 1px), #999 var(--baseline)), transparent;
background-size: 100% var(--baseline);
background-repeat: repeat-y;
......@@ -22,14 +21,15 @@ function snapBaseline(config){
}`
if(showBaseline) {
addcss(showBaselineCSS);
addcss(showBaselineCSS);
}
/* baseline position + vertical Rythm of paragraphs */
const paragraph = 'p';
verticalRythm(paragraph, baselineDoc, strict);
let baselinePosition = verticalRythm(paragraph, baselineDoc, strict);
document.getElementsByTagName('body')[0].style.setProperty('--baseline-position', "-" + baselinePosition + "px");
let baselinePositionCSS = ':root{ --baseline-position : -' + baselinePosition + 'px; }'
addcss(baselinePositionCSS);
/* elements to which the script applies */
["h1", "h2", "h3", "h4", "h5", "h6", "ul", "li", "blockquote", "figcaption", "adress", "dt", "dd", "hr", "pre"].forEach(element => snapTextElement(element, baselinePosition, baselineDoc, strict));
......@@ -45,11 +45,13 @@ ________________________________________________________________________________
*/
function snapTextElement(elementSelector, baselinePosition, baselineDoc, strict) {
let configStrict = strict;
verticalRythm(elementSelector, baselineDoc, configStrict);
let gapBaselineElem = verticalRythm(elementSelector, baselineDoc, configStrict);
let newgapBaselineElem = gapBaselineElem - baselinePosition;
let elem = document.querySelectorAll(elementSelector);
console.log(elem);
for(var i = 0; i < elem.length; i++) {
elem[i].style.position = "relative";
......
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