kollapsminoriteten/wp-content/plugins/blocksy-companion/static/bundle/sticky.js

1 line
11 KiB
JavaScript
Raw Normal View History

2025-12-12 13:13:07 +01:00
!function(){"use strict";var t={n:function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,{a:i}),i},d:function(e,i){for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},e=window.ctEvents,i=t.n(e),n=window.ctFrontend;const o=function(t,e,i){return Math.max(t,Math.min(e,i))},r=function(t,e,i){return e[0]+(e[1]-e[0])/(t[1]-t[0])*(i-t[0])},a=function(t){const e=getComputedStyle(t);let i=getComputedStyle(t.firstElementChild);if("none"===e.display)return 0;let n=parseFloat(e.borderTopWidth)+parseFloat(e.borderBottomWidth)+parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth),o=parseFloat(e.getPropertyValue("--height"));if(t.querySelector('[data-items] > [data-id="logo"]')){const e=getComputedStyle(t.querySelector('[data-items] > [data-id="logo"]'));let i=parseFloat(e.height);if(i+=parseFloat(e.marginTop)+parseFloat(e.marginBottom),t.querySelector(".site-logo-container")){const e=getComputedStyle(t.querySelector(".site-logo-container"));let n=parseFloat(e.getPropertyValue("--logo-shrink-height")||0);n>0&&(i=i-n+parseFloat(e.getPropertyValue("--logo-max-height")||50))}i>o&&(o=i)}let r=['[data-items] > [data-id*="widget-area"]','[data-items] > [data-id*="content-block"]','[data-items] > [data-id*="text"]','[data-items] > [data-id*="menu"]'].reduce(function(e,i){if(t.querySelector(i)){const n=getComputedStyle(t.querySelector(i));let o=parseFloat(n.height);if(o>e)return o}return e},0);return r>o&&(o=r),o+n},s=function(t){if(t.blcInitialHeight)return t.blcInitialHeight;let e=t.firstElementChild;t.firstElementChild.firstElementChild&&(e=t.firstElementChild.firstElementChild);let i=e.getBoundingClientRect().height;return t.blcInitialHeight=i,i},c=function(t,e=!0){if(t.blcStickyHeight)return t.blcStickyHeight;let i=s(t),n=getComputedStyle(t),o=getComputedStyle(t.firstElementChild);if(t.closest('[data-sticky*="yes"]')){let r=parseFloat(n.borderTopWidth)+parseFloat(n.borderBottomWidth)+parseFloat(o.borderTopWidth)+parseFloat(o.borderBottomWidth);e||(r=0);let s=t.getBoundingClientRect().height-r;const c=a(t);if(!(t.querySelector(".site-logo-container")&&parseFloat(getComputedStyle(t.querySelector(".site-logo-container")).getPropertyValue("--logo-sticky-shrink")||1)<1)&&(Math.round(s)!==Math.round(i)||Math.round(i)>Math.round(c)))return t.blcStickyHeight=t.getBoundingClientRect().height,s}let r=100;t.dataset.row.includes("middle")&&(r=n.getPropertyValue("--sticky-shrink"));return r&&(i*=parseFloat(r)/100),i},l=function(t=function(){return 0}){const e=document.querySelector(".ct-floating-bar");e&&e.style.setProperty("--header-sticky-height-animated",t())};let d=null;const u=function({stickyContainer:t,startPosition:e}){[...t.querySelectorAll('[data-row*="middle"]')].map(function(t){if(!t.querySelector('[data-id="logo"] .site-logo-container'))return;const i=t.querySelector('[data-id="logo"] .site-logo-container');let{initialHeight:n,stickyShrink:a,rowInitialHeight:l,rowStickyHeight:u}=function({logo:t,row:e}){if(d)return d;let i=parseFloat(getComputedStyle(t).getPropertyValue("--logo-max-height")||50);const n=parseFloat(getComputedStyle(t).getPropertyValue("--logo-sticky-shrink").toString().replace(",",".")||1);let o=s(e),r=c(e);return d={initialHeight:i,stickyShrink:n,rowInitialHeight:o,rowStickyHeight:r},d}({logo:i,row:t});const y=n*a;1!==a&&i.style.setProperty("--logo-shrink-height",r([e,e+Math.abs(l===u?n-y:l-u)],[1,a],o(e,e+Math.abs(l===u?n-y:l-u),scrollY))*n+"px")})};let y=null;const f=function({stickyContainer:t,containerInitialHeight:e,startPosition:i}){t.querySelector('[data-row*="middle"]')&&[t.querySelector('[data-row*="middle"]')].map(function(t){let{rowInitialHeight:e,rowStickyHeight:n}=function({row:t}){if(y)return y;let e=s(t),i=c(t);return y={rowInitialHeight:e,rowStickyHeight:i},y}({row:t});if(e!==n){let a=n;a=r([i,i+Math.abs(e-n)],[e,n],o(i,i+Math.abs(e-n),scrollY)),t.style.setProperty("--shrink-height",`${Math.round(a)}px`)}})},h=function({stickyContainer:t}){const e=[...t.