Advertisement
coentoro

Untitled

May 21st, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     function initHeadline_sticky() {
  2.           console.log('[DFP] initiate Headline stickiness');
  3.           var dfpOnceSticky = false,
  4.               hlStart = 0,
  5.               hlStickyTimer;
  6.           document.addEventListener("scroll", function() {
  7.               var dfpHL = document.getElementById("div-gpt-ad-liputan6-hl");
  8.               var hlPos = dfpHL && dfpHL.getBoundingClientRect();
  9.               if (hlPos && !dfpOnceSticky && hlPos.top <= 10) {
  10.                   hlStart = dfpHL.offsetTop;
  11.                   dfpHL.classList.add("dfp-hl-sticky");
  12.                   dfpOnceSticky = true;
  13.                   dfp_videoHLStickyState = dfpOnceSticky;
  14.                   hlStickyTimer = window.setTimeout(function() {
  15.                       dfpHL.style.marginTop = -(dfpHL.clientHeight) + "px"
  16.                       setTimeout(function() {
  17.                           dfpHL.classList.remove("dfp-hl-sticky");
  18.                           dfpHL.style.marginTop = "0px";
  19.                       }, 700);
  20.                   }, 5000);
  21.               }
  22.               if (dfpOnceSticky && window.scrollY < (hlStart - 70) && hlStickyTimer) {
  23.                   window.clearTimeout(hlStickyTimer);
  24.                   dfpHL.classList.remove("dfp-hl-sticky");
  25.                   dfpHL.style.marginTop = "10px";
  26.               }
  27.           });
  28.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement