functions-new-landing.js 894 B

12345678910111213141516171819202122232425262728293031323334
  1. jQuery(document).ready(function($) {
  2. (function() {
  3. jqElemNavSentinel = $('#ch-ggs-web-suite-landing-nav-trigger');
  4. jqElemNav = $('#ch-ggs-web-suite-landing-nav');
  5. if (jqElemNavSentinel.length === 0 || jqElemNav.length === 0) return;
  6. const sentinelEl = jqElemNavSentinel[0];
  7. const navEl = jqElemNav[0];
  8. const stuckClass = 'stuck';
  9. if ("IntersectionObserver" in window &&
  10. "IntersectionObserverEntry" in window &&
  11. "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
  12. const handler = function(entries) {
  13. if (navEl) {
  14. if (!entries[0].isIntersecting) {
  15. navEl.classList.add(stuckClass);
  16. } else {
  17. navEl.classList.remove(stuckClass);
  18. }
  19. }
  20. }
  21. const observer = new window.IntersectionObserver(handler);
  22. observer.observe(sentinelEl);
  23. }
  24. })();
  25. })