HEX
Server: LiteSpeed
System: Linux dal1.hostclusters.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64
User: vslw (1496)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: /home/vslw/public_html/wp-content/themes/soledad/js/sticky_share_v2.js
function initStickyShareBox() {
  const posts = document.querySelectorAll('.post');
  const isRTL = document.documentElement.dir === 'rtl'; // detect RTL

  posts.forEach(post => {
    const shareBox = post.querySelector('.tags-share-box');
    if (!shareBox) return;

    const shareBoxHeight = shareBox.offsetHeight;

    function getStickyOffset() {
      const header = document.querySelector('.penci_builder_sticky_header_desktop');
      const headern = document.querySelector('.sticky-wrapper');
      const poststicky = document.querySelector('.penci-post-sticky-nav');
      const headerHeight = header ? header.offsetHeight : 0;
      const poststickyHeight = poststicky ? poststicky.offsetHeight : 0;
      const headernHeight = headern ? headern.offsetHeight : 0;
      return headerHeight + poststickyHeight + headernHeight + 60;
    }

    function updatePosition() {
      const postRect = post.getBoundingClientRect();
      const postTop = postRect.top + window.scrollY;
      const postBottom = postTop + post.offsetHeight;
      const scrollY = window.scrollY;

      const offset = getStickyOffset();

      // Calculate fixed alignment
      const shareRect = shareBox.getBoundingClientRect();
      const sidePos = isRTL
        ? window.innerWidth - (shareRect.left + shareRect.width)
        : shareRect.left;

      if (scrollY + offset > postTop && scrollY + shareBoxHeight + offset < postBottom) {
        shareBox.style.position = 'fixed';
        shareBox.style.top = offset + 'px';

        if (isRTL) {
          shareBox.style.right = sidePos + 'px';
          shareBox.style.left = '';
        } else {
          shareBox.style.left = sidePos + 'px';
          shareBox.style.right = '';
        }
      } else if (scrollY + shareBoxHeight + offset >= postBottom) {
        shareBox.style.position = 'absolute';
        shareBox.style.top = (post.offsetHeight - shareBoxHeight) + 'px';
        shareBox.style.left = '';
        shareBox.style.right = '';
      } else {
        shareBox.style.position = 'absolute';
        shareBox.style.top = '0px';
        shareBox.style.left = '';
        shareBox.style.right = '';
      }
    }

    window.addEventListener('scroll', updatePosition);
    window.addEventListener('resize', updatePosition);
    updatePosition();
  });
}

document.addEventListener('DOMContentLoaded', initStickyShareBox);