@ibragim-dev-org/ui-forge-library 1.4.69 → 1.4.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -637,11 +637,27 @@ class StickyObserverDirective {
637
637
  this.renderer.setStyle(this.sentinel, 'opacity', '0');
638
638
  const parent = stickyEl.parentElement;
639
639
  parent.insertBefore(this.sentinel, stickyEl);
640
- this.observer = new IntersectionObserver(([entry]) => {
641
- this.$isStuck.set(entry.boundingClientRect.top < 0);
642
- }, { threshold: [1] });
640
+ const root = this.findScrollParent(stickyEl);
641
+ const stickyTop = parseFloat(getComputedStyle(stickyEl).top) || 0;
642
+ // The sentinel is "stuck" once it leaves the scroll root through the sticky offset line.
643
+ this.observer = new IntersectionObserver((entries) => {
644
+ const entry = entries[entries.length - 1];
645
+ const rootTop = entry.rootBounds?.top ?? 0;
646
+ this.$isStuck.set(!entry.isIntersecting && entry.boundingClientRect.top < rootTop);
647
+ }, { root, rootMargin: `-${Math.ceil(stickyTop)}px 0px 0px 0px`, threshold: [0, 1] });
643
648
  this.observer.observe(this.sentinel);
644
649
  }
650
+ findScrollParent(el) {
651
+ let node = el.parentElement;
652
+ while (node) {
653
+ const overflowY = getComputedStyle(node).overflowY;
654
+ if (overflowY === 'auto' || overflowY === 'scroll') {
655
+ return node;
656
+ }
657
+ node = node.parentElement;
658
+ }
659
+ return null;
660
+ }
645
661
  ngOnDestroy() {
646
662
  this.observer?.disconnect();
647
663
  this.sentinel?.remove();