function styleCutoutContainer(duration, cutoutContainer) { const articleHeader = document.getElementsByClassName('article__header')[0]; const numOfCircles = Math.min(10, Math.floor((duration / 60) / 2)) + 2; const h = getElementOffset(cutoutContainer).height; const w = getElementOffset(cutoutContainer).width; let size = (h * w) / 8000; const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); canvas.width = w; canvas.height = h; canvas.className = 'cutout__background'; // Draw Circles for (let i = 0; i < numOfCircles; i++) { const x = Math.floor(Math.random() * (w - 0) + 1); ctx.beginPath(); ctx.arc(x, h / 2, size, 0, Math.PI * 2, true); ctx.closePath(); ctx.fillStyle = getColor(); ctx.fill(); size = size * 1.2; } articleHeader.appendChild(canvas); cutoutContainer.dataset.background = 'true'; }
function movePullQuotes() { let i; let pullQuote; const pullQuotes = document.getElementsByClassName('element-pullquote'); for (i = 0; i < pullQuotes.length; i++) { pullQuote = pullQuotes[i]; pullQuote.dataset.offset = getElementOffset(pullQuote).top; } }
function init() { newBlockHtml = ''; liveblogStartPos = getElementOffset(document.getElementsByClassName('article__body--liveblog')[0]); setupGlobals(); keyEvents(); window.liveblogTime(); window.addEventListener('scroll', debounce(updateBlocksOnScroll, 100, true)); liveMore(); trackLiveBlogEpic(); initTwitter(); initYoutube(); setInterval(window.liveblogTime, 30000); }