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

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';
@@ -786,6 +786,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
786
786
 
787
787
  class StableScrollDirective {
788
788
  host;
789
+ destroyRef;
789
790
  el;
790
791
  lastScrollHeight = 0;
791
792
  /** Emit when user reaches top threshold */
@@ -796,16 +797,52 @@ class StableScrollDirective {
796
797
  $topThreshold = input(0, ...(ngDevMode ? [{ debugName: "$topThreshold" }] : []));
797
798
  /** Bottom threshold in px or percentage (0–1). Default: 0 (exact bottom). */
798
799
  $bottomThreshold = input(0, ...(ngDevMode ? [{ debugName: "$bottomThreshold" }] : []));
799
- constructor(host) {
800
+ constructor(host, destroyRef) {
800
801
  this.host = host;
802
+ this.destroyRef = destroyRef;
801
803
  this.el = this.host.nativeElement;
802
804
  }
805
+ scrolling$ = new Subject();
806
+ scrollEnd$ = new Subject();
807
+ isScrolling = false;
808
+ resizeObserver;
809
+ get scrolling() {
810
+ return this.isScrolling;
811
+ }
803
812
  ngAfterViewInit() {
804
813
  this.lastScrollHeight = this.el.scrollHeight;
805
814
  fromEvent(this.el, 'scroll')
806
- .pipe(throttleTime(50), tap(() => this.onScroll()))
815
+ .pipe(throttleTime(50), tap(() => {
816
+ this.isScrolling = true;
817
+ this.scrolling$.next();
818
+ this.onScroll();
819
+ }), takeUntilDestroyed(this.destroyRef))
820
+ .subscribe();
821
+ this.scrolling$
822
+ .pipe(debounceTime(120), tap(() => {
823
+ this.isScrolling = false;
824
+ this.scrollEnd$.next();
825
+ }), takeUntilDestroyed(this.destroyRef))
826
+ .subscribe();
827
+ this.resizeObserver = new ResizeObserver(() => {
828
+ if (!this.isScrolling) {
829
+ this.captureBeforeChange();
830
+ this.restoreScrollPosition();
831
+ }
832
+ });
833
+ this.resizeObserver.observe(this.el);
834
+ fromEvent(window, 'resize')
835
+ .pipe(throttleTime(50), tap(() => {
836
+ if (!this.isScrolling) {
837
+ this.captureBeforeChange();
838
+ this.restoreScrollPosition();
839
+ }
840
+ }), takeUntilDestroyed(this.destroyRef))
807
841
  .subscribe();
808
842
  }
843
+ ngOnDestroy() {
844
+ this.resizeObserver.disconnect();
845
+ }
809
846
  onScroll() {
810
847
  const { scrollTop, scrollHeight, clientHeight } = this.el;
811
848
  // --- TOP THRESHOLD ---
@@ -830,11 +867,13 @@ class StableScrollDirective {
830
867
  }
831
868
  /** Call this AFTER Angular renders new items */
832
869
  restoreScrollPosition() {
833
- const newHeight = this.el.scrollHeight;
834
- const diff = newHeight - this.lastScrollHeight;
835
- this.el.scrollTop += diff;
870
+ requestAnimationFrame(() => {
871
+ const newHeight = this.el.scrollHeight;
872
+ const diff = newHeight - this.lastScrollHeight;
873
+ this.el.scrollTop += diff;
874
+ });
836
875
  }
837
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: StableScrollDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
876
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: StableScrollDirective, deps: [{ token: i0.ElementRef }, { token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Directive });
838
877
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: StableScrollDirective, isStandalone: true, selector: "[stableScroll]", inputs: { $topThreshold: { classPropertyName: "$topThreshold", publicName: "$topThreshold", isSignal: true, isRequired: false, transformFunction: null }, $bottomThreshold: { classPropertyName: "$bottomThreshold", publicName: "$bottomThreshold", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { reachedTop: "reachedTop", reachedBottom: "reachedBottom" }, ngImport: i0 });
839
878
  }
840
879
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: StableScrollDirective, decorators: [{
@@ -842,7 +881,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
842
881
  args: [{
843
882
  selector: '[stableScroll]',
844
883
  }]
845
- }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { reachedTop: [{ type: i0.Output, args: ["reachedTop"] }], reachedBottom: [{ type: i0.Output, args: ["reachedBottom"] }], $topThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "$topThreshold", required: false }] }], $bottomThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "$bottomThreshold", required: false }] }] } });
884
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.DestroyRef }], propDecorators: { reachedTop: [{ type: i0.Output, args: ["reachedTop"] }], reachedBottom: [{ type: i0.Output, args: ["reachedBottom"] }], $topThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "$topThreshold", required: false }] }], $bottomThreshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "$bottomThreshold", required: false }] }] } });
846
885
 
847
886
  class CenterEllipsisPipe {
848
887
  transform(value, visibleStart = 4, visibleEnd = 4) {