{"version":3,"names":[],"mappings":"","sources":["home.js"],"sourcesContent":["//Vanilla JS/jQuery\n\n(function($) {\n  var pageTitle = document.querySelector('.page-title');\n  var header = document.querySelector('.page-header');\n  var cont = pageTitle.parentElement;\n\n  //Page title height/width adjust\n  var elDims, contH, contW, fontSize;\n\n  function getDims() {\n    elH = pageTitle.getBoundingClientRect().height;\n    elW = pageTitle.parentElement.scrollWidth;\n    contH = $(header).height();\n    contW = Math.round(cont.getBoundingClientRect().width);\n    fontSize = parseInt(\n      window.getComputedStyle(pageTitle, null).getPropertyValue('font-size')\n    );\n    //console.log(elH, contH, elW, contW, fontSize);\n  }\n\n  getDims();\n  index = 0;\n  if (elH > contH || elW > contW) {\n    while (index < 70 && (elH > contH || elW > contW)) {\n      pageTitle.style.fontSize = fontSize - 2 + 'px';\n      getDims();\n      index++;\n    }\n  } else {\n    while (index < 70 && (elH <= contH && elW <= contW)) {\n      pageTitle.style.fontSize = fontSize + 2 + 'px';\n      getDims();\n      if (elH > contH || elW > contW) {\n        //Roll back final adjustment if it makes the content exceed the container\n        pageTitle.style.fontSize = fontSize - 2 + 'px';\n        index = 70;\n      }\n      index++;\n    }\n  }\n  header.classList.add('initialized');\n})(jQuery);\n\n//Set height of masonry layout for audiences content\n(function($) {\n  var cont = document.querySelector('.wp-block-audiences');\n  var elH = 0;\n  var els = cont.querySelectorAll('figure');\n  //Fit height to first two images\n  for (var e = 0; e < 2; e++) {\n    elH += els[e].offsetHeight;\n  }\n  cont.querySelector(':scope > .wp-block-group__inner-container').style.height =\n    Math.ceil(elH) + 2 + 'px';\n})(jQuery);\n\n//Scroll animations\n(function($) {\n  var controller = new ScrollMagic.Controller();\n\n  //Intro image after header\n  new ScrollMagic.Scene({\n    triggerElement: '.wp-block-homepage-image-after-intro img',\n  })\n    .setTween('.wp-block-homepage-image-after-intro img', 2, {\n      filter: 'grayScale(0)',\n    })\n    //.addIndicators()\n    .addTo(controller);\n\n  //Audiences block images\n  var audiencesImages = Array.from(\n    document.querySelectorAll('.wp-block-audiences figure img')\n  );\n  if (window.innerWidth > 1200) {\n    audiencesImages.forEach((el, e) => {\n      const index = e == 1 ? 2 : e == 2 ? 1 : e;\n      //const index = e;\n      new ScrollMagic.Scene({\n        triggerElement: el.parentElement,\n        duration: 2000 - 500 * index,\n        triggerHook: 1,\n      })\n        .setTween(el, 1, {\n          transform: 'translateY(0)',\n        })\n        .addTo(controller);\n    });\n  } else if (window.innerWidth > 760) {\n    audiencesImages.forEach((el, e) => {\n      new ScrollMagic.Scene({\n        triggerElement: el.parentElement,\n        duration: 1100,\n        triggerHook: 1,\n        offset: (e - 1) * 2 * (-0.2 * window.innerHeight),\n      })\n        .setTween(el, 1, {\n          top: '-150%',\n        })\n        .addTo(controller);\n    });\n  } else {\n    audiencesImages.forEach((el, e) => {\n      new ScrollMagic.Scene({\n        triggerElement: el.parentElement,\n        duration: 1000,\n        triggerHook: 1,\n        offset: e * (-0.1 * window.innerHeight),\n      })\n        .setTween(el, 1, {\n          top: '-200%',\n        })\n        .addTo(controller);\n    });\n  }\n\n  // Bushwick (Serving Brooklyn and beyond) block sticky intro\n  // Appear and stick\n\n  var blockBushwick = document.querySelector('.wp-block-bushwick');\n  var blockBushwickContent = blockBushwick.querySelector(\n    '.wp-block-group__inner-container'\n  );\n  var blockBushwickSibling = blockBushwick.nextElementSibling;\n  new ScrollMagic.Scene({\n    triggerElement: blockBushwick,\n    triggerHook: 0,\n  })\n    .setTween(\n      TweenMax.set(blockBushwickContent, {\n        className: 'wp-block-group__inner-container active sticky',\n      })\n    )\n    .addTo(controller);\n\n  //Unstick\n  var blockBushwickUnstickTween = new ScrollMagic.Scene({\n    triggerElement: blockBushwickSibling,\n    triggerHook: 1,\n  })\n    .setTween(\n      TweenMax.set(blockBushwickContent, {\n        className: 'wp-block-group__inner-container',\n      })\n    )\n    .on('start', function(e) {\n      if (e.scrollDirection === 'FORWARD') {\n        //Manually remove sticky since ScrollMagic wants to revert to no classes rather than sticky state classes\n        setTimeout(() => {\n          blockBushwickContent.classList.remove('sticky');\n        }, 10);\n      } else if (e.scrollDirection === 'REVERSE') {\n        //Manually re-add sticky since ScrollMagic wants to revert to no classes rather than sticky state classes\n        setTimeout(() => {\n          blockBushwickContent.classList.add('sticky');\n        }, 10);\n      }\n    })\n    .addTo(controller);\n\n  // NYC block BG\n  if (window.innerWidth > window.innerHeight) {\n    new ScrollMagic.Scene({\n      triggerElement: '.wp-block-nyc',\n      duration: 1000,\n      triggerHook: 1,\n    })\n      .setTween('.wp-block-nyc figure img', 1, { top: '-100vh' })\n      .addTo(controller);\n  } else {\n    new ScrollMagic.Scene({\n      triggerElement: '.wp-block-nyc',\n      duration: 1000,\n      triggerHook: 1,\n    })\n      .setTween('.wp-block-nyc figure img', 1, { top: '-100vw' })\n      .addTo(controller);\n  }\n\n  // NYC block header\n  new ScrollMagic.Scene({\n    triggerElement: '.wp-block-nyc',\n    duration: 800,\n    triggerHook: 1,\n  })\n    .setTween('.wp-block-nyc h2', 1, { bottom: '130px' })\n    .addTo(controller);\n\n  var blockNYC = document.querySelector('.wp-block-nyc');\n  var blockNYCContent = blockNYC.querySelector(\n    '.wp-block-group__inner-container'\n  );\n  var blockNYCSibling = blockNYC.nextElementSibling;\n  var blockNYCHeader = blockNYC.querySelector('h2');\n  var blockNYCHeaderGlyph = parseInt(\n    window.getComputedStyle(blockNYCHeader).lineHeight\n  );\n\n  blockNYCHeader.innerHTML = blockNYCHeader.innerHTML.replace(\n    'Welcom',\n    \"<span class='span-reference'>Welcom</span>\"\n  );\n  var blockNYCHeaderReference = blockNYCHeader.querySelector('.span-reference');\n  var blockNYCHeaderRect = blockNYCHeaderReference.getBoundingClientRect();\n\n  blockNYCHeader.style.transformOrigin =\n    100 * ((blockNYCHeaderRect.width + 4) / blockNYCHeader.clientWidth) +\n    '% .66em';\n\n  new ScrollMagic.Scene({\n    triggerElement: '.wp-block-nyc',\n    duration: 2000,\n    triggerHook: 0,\n  })\n    .setTween('.wp-block-nyc h2', {\n      scale: 100,\n      ease: 'power3.in',\n    })\n    .addTo(controller);\n\n  // new ScrollMagic.Scene({\n  //   triggerElement: '.wp-block-nyc',\n  //   duration: 2000,\n  //   triggerHook: 0,\n  // })\n  //   .setTween('.wp-block-nyc', { opacity: '0', ease: 'power3.in' })\n  //   .addTo(controller);\n\n  // NYC block sticky intro\n  // Appear and stick\n\n  new ScrollMagic.Scene({\n    triggerElement: blockNYC,\n    triggerHook: 0,\n  })\n    .setTween(\n      TweenMax.set(blockNYCContent, {\n        className: 'wp-block-group__inner-container active sticky',\n      })\n    )\n    .addTo(controller);\n\n  //Unstick\n  new ScrollMagic.Scene({\n    triggerElement: blockNYCSibling,\n    triggerHook: 1,\n  })\n    .on('start', function(e) {\n      if (e.scrollDirection === 'FORWARD') {\n        //Manually remove sticky since ScrollMagic wants to revert to no classes rather than sticky state classes\n        setTimeout(() => {\n          blockNYCContent.classList.remove('sticky');\n        }, 10);\n      } else if (e.scrollDirection === 'REVERSE') {\n        //Manually re-add sticky since ScrollMagic wants to revert to no classes rather than sticky state classes\n        setTimeout(() => {\n          blockNYCContent.classList.add('sticky');\n        }, 10);\n      }\n    })\n    .addTo(controller);\n\n  // Success Story/Lives Changed block sticky\n  // Appear and stick\n\n  var blockLC = document.querySelector('.successstory-list__outer');\n  var blockLCSibling = blockLC.nextElementSibling;\n\n  if (window.innerWidth > 1023) {\n    blockLC.classList.add('transition');\n    new ScrollMagic.Scene({\n      triggerElement: blockLC.querySelector('.successstory-list__post'),\n      triggerHook: 1,\n    })\n      .setTween(\n        TweenMax.set(blockLC, {\n          className: 'successstory-list__outer active sticky transition',\n        })\n      )\n      .addTo(controller);\n\n    //Unstick\n    new ScrollMagic.Scene({\n      triggerElement: blockLCSibling,\n      triggerHook: 1,\n    })\n      .on('start', function(e) {\n        if (e.scrollDirection === 'FORWARD') {\n          //Manually remove sticky since ScrollMagic wants to revert to no classes rather than sticky state classes\n          setTimeout(() => {\n            blockLC.classList.remove('sticky');\n          }, 10);\n        } else if (e.scrollDirection === 'REVERSE') {\n          //Manually re-add sticky since ScrollMagic wants to revert to no classes rather than sticky state classes\n          setTimeout(() => {\n            blockLC.classList.add('sticky');\n          }, 10);\n        }\n      })\n      .addTo(controller);\n  } else {\n    blockLC.style.height = 'auto';\n    blockLC.style.minHeight = '100vh';\n  }\n\n  //Success Story Gallery Block content\n  new ScrollMagic.Scene({\n    triggerElement: '.successstory-list__wrapper',\n    triggerHook: 0.75,\n    duration: 500,\n  })\n    .setTween('.successstory-list__preheader + .row', {\n      css: { transform: 'translateY(0)' },\n    })\n    .addTo(controller);\n\n  // Potential block images\n  Array.from(\n    document.querySelectorAll('.wp-block-potential figure img')\n  ).forEach((el, e) => {\n    new ScrollMagic.Scene({\n      triggerElement: el.parentElement,\n      duration: 1500,\n      triggerHook: 1,\n    })\n      .setTween(el, 2, { transform: 'translateY(0)' })\n      .addTo(controller);\n  });\n\n  // Potential block header\n  new ScrollMagic.Scene({\n    triggerElement: '.wp-block-potential',\n    duration: 1000,\n    triggerHook: 1,\n  })\n    .setTween('.wp-block-potential h2', 1, { transform: 'translateY(0)' })\n    .addTo(controller);\n\n  //Join block BG\n  new ScrollMagic.Scene({\n    triggerElement: '.wp-block-join figure',\n    triggerHook: 0.1,\n  })\n    .setTween('.wp-block-join figure img', 2, { filter: 'grayScale(0)' })\n    //.addIndicators()\n    .addTo(controller);\n\n  Array.from(\n    document.querySelectorAll('.wp-block-join .wp-block-join__group')\n  ).forEach((el, e) => {\n    new ScrollMagic.Scene({\n      triggerElement: el,\n      duration: 300,\n      offset: -420 + 100 * (e + 1),\n      triggerHook: 0.75,\n    })\n      .setTween(el, 2, { opacity: 1 })\n      //.addIndicators()\n      .addTo(controller);\n  });\n\n  //Join block BG\n  // new ScrollMagic.Scene({\n  //   triggerElement: '.wp-block-join',\n  // })\n  //   .setTween('.wp-block-join h2', 1, { opacity: 1 })\n  //   //.addIndicators()\n  //   .addTo(controller);\n})(jQuery);\n"],"file":"home.js"}