@ibragim-dev-org/ui-forge-library 1.4.31 → 1.4.32

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.
@@ -1,6 +1,6 @@
1
1
  import * as i2$1 from '@angular/router';
2
2
  import { NavigationEnd, NavigationStart, ActivationEnd } from '@angular/router';
3
- import { BehaviorSubject, filter, take, scheduled, fromEvent, asyncScheduler, mergeAll, tap, debounceTime, throttleTime, Subscription, timer, switchMap, interval, takeWhile, finalize, Subject, takeUntil } from 'rxjs';
3
+ import { BehaviorSubject, filter, take, scheduled, fromEvent, asyncScheduler, mergeAll, tap, debounceTime, Subject, throttleTime, Subscription, timer, switchMap, interval, takeWhile, finalize, takeUntil } from 'rxjs';
4
4
  import * as i0 from '@angular/core';
5
5
  import { model, effect, Directive, Injectable, output, Input, input, PLATFORM_ID, Inject, EventEmitter, Output, Pipe, Attribute, ChangeDetectionStrategy, Component, signal, computed, viewChild, untracked, Injector, afterRenderEffect, contentChildren, contentChild, ViewChildren } from '@angular/core';
6
6
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
@@ -800,11 +800,38 @@ class StableScrollDirective {
800
800
  this.host = host;
801
801
  this.el = this.host.nativeElement;
802
802
  }
803
+ scrolling$ = new Subject();
804
+ scrollEnd$ = new Subject();
805
+ isScrolling = false;
806
+ resizeObserver;
807
+ get scrolling() {
808
+ return this.isScrolling;
809
+ }
803
810
  ngAfterViewInit() {
804
811
  this.lastScrollHeight = this.el.scrollHeight;
805
812
  fromEvent(this.el, 'scroll')
806
- .pipe(throttleTime(50), tap(() => this.onScroll()))
813
+ .pipe(throttleTime(50), tap(() => {
814
+ this.isScrolling = true;
815
+ this.scrolling$.next();
816
+ this.onScroll();
817
+ }))
818
+ .subscribe();
819
+ this.scrolling$
820
+ .pipe(debounceTime(120), tap(() => {
821
+ this.isScrolling = false;
822
+ this.scrollEnd$.next();
823
+ }))
807
824
  .subscribe();
825
+ this.resizeObserver = new ResizeObserver(() => {
826
+ if (!this.isScrolling) {
827
+ this.captureBeforeChange();
828
+ requestAnimationFrame(() => this.restoreScrollPosition());
829
+ }
830
+ });
831
+ this.resizeObserver.observe(this.el);
832
+ }
833
+ ngOnDestroy() {
834
+ this.resizeObserver.disconnect();
808
835
  }
809
836
  onScroll() {
810
837
  const { scrollTop, scrollHeight, clientHeight } = this.el;