2A News

Push for Firearm Safety Instruction in Arizona Public Schools Advances

Reading Time: 1:52 min

There was a time when sporting traditions such as hunting and target shooting were passed down through the generations. Parents and grandparents taught children and grandchildren the fine art of…

View post

Push for Firearm Safety Instruction in Arizona Public Schools Advances

Reading Time: 1:52 min

There was a time when sporting traditions such as hunting and target shooting were passed down through the generations. Parents and grandparents taught children and grandchildren the fine art of…

View post

Proposal Would Give Victims in ‘Gun-Free’ Zones Legal Recourse

Reading Time: 1:57 min

The ridiculousness of so-called “gun-free” zones is tough to overstate. By definition, violent criminals do not care one whit about the law and actually prefer these soft targets where good…

View post

ATF Continues to Enforce Pistol Brace Ban After It Was Eliminated

Reading Time: 1:55 min

Just because there was a changing of the guard at a high-profile government agency and some welcome reforms were introduced does not mean all is well, far from it. The…

View post

Kentucky Close to Approving Young Adult Concealed Carry

Reading Time: 1:51 min

A bill to establish concealed carry rights for young adults under 21 in Kentucky breezed through the Legislature and is headed to Gov. Andy Beshear’s (D) desk. And the tally…

View post

Illinois Lawmaker Wants to Mandate Microstamping Ammunition

Reading Time: 1:51 min

Leave it to the Land of Lincoln to concoct a gun control scheme rooted solely in virtue signaling and political grandstanding that does nothing to enhance public safety. Illinois officials…

View post
<script>
  /*Source: https://github.com/Krzysztof-Antosik/Two-direction-Sticky-Sidebar*/
  
  // Verificar el ancho de pantalla al cargar y redimensionar
  function checkScreenWidth() {
    if (window.innerWidth <= 767) {
      // Si la pantalla es menor o igual a 676px, no ejecutar el código
      return;
    }

    const stickyElement = document.querySelector('.fb-sidebar__aside');
    const startPosition = stickyElement.getBoundingClientRect().top;

    let endScroll = window.innerHeight - stickyElement.offsetHeight - 500;
    let currPos = window.scrollY;
    let screenHeight = window.innerHeight;
    let stickyElementHeight = stickyElement.offsetHeight;
    let topGap = 40;
    let bottomGap = 40;

    setTimeout(() => {
      if (stickyElement.hasAttribute('data-top-gap')) {
        const dataTopGap = stickyElement.getAttribute('data-top-gap');
        topGap = dataTopGap === 'auto' ? startPosition : parseInt(dataTopGap);
      }

      if (stickyElement.hasAttribute('data-bottom-gap')) {
        bottomGap = parseInt(stickyElement.getAttribute('data-bottom-gap'));
      }
    }, 100);

    stickyElement.style.position = 'sticky';
    stickyElement.style.top = `${topGap}px`;
    stickyElement.style.height = 'fit-content';

    function positionStickySidebar() {
      endScroll = window.innerHeight - stickyElement.offsetHeight - bottomGap;
      const stickyElementTop = parseInt(stickyElement.style.top.replace('px', ''));

      if (stickyElementHeight + topGap + bottomGap > screenHeight) {
        if (window.scrollY < currPos) {
          if (stickyElementTop < topGap) {
            stickyElement.style.top = `${stickyElementTop + currPos - window.scrollY}px`;
          } else if (stickyElementTop >= topGap && stickyElementTop !== topGap) {
            stickyElement.style.top = `${topGap}px`;
          }
        } else {
          if (stickyElementTop > endScroll) {
            stickyElement.style.top = `${stickyElementTop + currPos - window.scrollY}px`;
          } else if (stickyElementTop < endScroll && stickyElementTop !== endScroll) {
            stickyElement.style.top = `${endScroll}px`;
          }
        }
      } else {
        stickyElement.style.top = `${topGap}px`;
      }
      currPos = window.scrollY;
    }

    function stickyElementToMe() {
      stickyElement.style.top = `${topGap}px`;
    }

    function updateSticky() {
      screenHeight = window.innerHeight;
      stickyElementHeight = stickyElement.offsetHeight;
      positionStickySidebar();
    }

    setTimeout(() => {
      window.addEventListener('resize', () => {
        currPos = window.scrollY;
        updateSticky();
      });

      document.addEventListener('scroll', updateSticky, {
        capture: true,
        passive: true
      });
    }, 1000);
  }

  // Verificar el ancho de pantalla al cargar y redimensionar
  window.addEventListener('load', checkScreenWidth);
  window.addEventListener('resize', checkScreenWidth);
</script>