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

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, Subscription, timer, switchMap, interval, takeWhile, finalize, Subject, takeUntil } from 'rxjs';
3
+ import { BehaviorSubject, filter, take, scheduled, fromEvent, asyncScheduler, mergeAll, tap, debounceTime, throttleTime, Subscription, timer, switchMap, interval, takeWhile, finalize, Subject, 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';
@@ -784,6 +784,66 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
784
784
  args: [PLATFORM_ID]
785
785
  }] }], propDecorators: { sizeChange: [{ type: i0.Output, args: ["sizeChange"] }] } });
786
786
 
787
+ class StableScrollDirective {
788
+ host;
789
+ el;
790
+ lastScrollHeight = 0;
791
+ /** Emit when user reaches top threshold */
792
+ reachedTop = output();
793
+ /** Emit when user reaches bottom threshold */
794
+ reachedBottom = output();
795
+ /** Top threshold in px or percentage (0–1). Default: 0 (exact top). */
796
+ $topThreshold = input(0, ...(ngDevMode ? [{ debugName: "$topThreshold" }] : []));
797
+ /** Bottom threshold in px or percentage (0–1). Default: 0 (exact bottom). */
798
+ $bottomThreshold = input(0, ...(ngDevMode ? [{ debugName: "$bottomThreshold" }] : []));
799
+ constructor(host) {
800
+ this.host = host;
801
+ this.el = this.host.nativeElement;
802
+ }
803
+ ngAfterViewInit() {
804
+ this.lastScrollHeight = this.el.scrollHeight;
805
+ fromEvent(this.el, 'scroll')
806
+ .pipe(throttleTime(50), tap(() => this.onScroll()))
807
+ .subscribe();
808
+ }
809
+ onScroll() {
810
+ const { scrollTop, scrollHeight, clientHeight } = this.el;
811
+ // --- TOP THRESHOLD ---
812
+ const topLimit = this.$topThreshold() <= 1
813
+ ? scrollHeight * this.$topThreshold() // percentage
814
+ : this.$topThreshold(); // px
815
+ if (scrollTop <= topLimit) {
816
+ this.reachedTop.emit();
817
+ }
818
+ // --- BOTTOM THRESHOLD ---
819
+ const bottomLimit = this.$bottomThreshold() <= 1
820
+ ? scrollHeight * this.$bottomThreshold() // percentage
821
+ : this.$bottomThreshold(); // px
822
+ const distanceFromBottom = scrollHeight - (scrollTop + clientHeight);
823
+ if (distanceFromBottom <= bottomLimit) {
824
+ this.reachedBottom.emit();
825
+ }
826
+ }
827
+ /** Call this BEFORE you change the data */
828
+ captureBeforeChange() {
829
+ this.lastScrollHeight = this.el.scrollHeight;
830
+ }
831
+ /** Call this AFTER Angular renders new items */
832
+ restoreScrollPosition() {
833
+ const newHeight = this.el.scrollHeight;
834
+ const diff = newHeight - this.lastScrollHeight;
835
+ this.el.scrollTop += diff;
836
+ }
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 });
838
+ 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
+ }
840
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: StableScrollDirective, decorators: [{
841
+ type: Directive,
842
+ args: [{
843
+ selector: '[stableScroll]',
844
+ }]
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 }] }] } });
846
+
787
847
  class CenterEllipsisPipe {
788
848
  transform(value, visibleStart = 4, visibleEnd = 4) {
789
849
  if (!value) {
@@ -4370,5 +4430,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
4370
4430
  * Generated bundle index. Do not edit.
4371
4431
  */
4372
4432
 
4373
- export { Alert, AlertType, AppIconsLibrary, CalendarUtils, CenterEllipsisPipe, ContainerSizeDirective, CountryService, DateUtils, EMAIL, FocusDirective, HAS_CAPITAL_CASE, HAS_NUMBER, HAS_SMALL_CASE, HAS_SPECIAL_CHARTERS, HoverTipDirective, IconComponent, LazyImgDirective, MIN_LENGTH, MaskGradientDirective, RouterBehavior, SkeletonDirective, StickyObserverDirective, ThemeService, TrackLifecycleDirective, UIInputDateDirective, UIPhoneNumberDirective, UiAccordionComponent, UiAlertMessagesOverlayService, UiAlertMessagesService, UiAvatarDirective, UiButtonDirective, UiCalendarDropdownDirective, UiCodeDirective, UiCopyButtonDirective, UiDailyCalendarDirective, UiDropdownContainerDirective, UiDropdownService, UiFieldBaseDirective, UiImageDirective, UiInputCheckboxDirective, UiInputCountryDirective, UiInputDirective, UiInputSelectDirective, UiInputSequenceDirective, UiInputTimeDirective, UiMonthlyCalendarDirective, UiPaginationDirective, UiPopupBackdropDirective, UiPopupBackdropService, UiPopupContainerDirective, UiPopupImageDirective, UiPopupInstance, UiPopupService, UiSelectButtonsDirective, UiTabsDirective, UiTimeDropdownDirective, UiValidationErrorsDirective, UiYearlyCalendarDirective, createNavigation, createUrl, createUrlTree, emptyCountry, extractParam, getAspectRatioFit, isBrowser, navigateByUrl, stringToColorGradient, stringToHslColor };
4433
+ export { Alert, AlertType, AppIconsLibrary, CalendarUtils, CenterEllipsisPipe, ContainerSizeDirective, CountryService, DateUtils, EMAIL, FocusDirective, HAS_CAPITAL_CASE, HAS_NUMBER, HAS_SMALL_CASE, HAS_SPECIAL_CHARTERS, HoverTipDirective, IconComponent, LazyImgDirective, MIN_LENGTH, MaskGradientDirective, RouterBehavior, SkeletonDirective, StableScrollDirective, StickyObserverDirective, ThemeService, TrackLifecycleDirective, UIInputDateDirective, UIPhoneNumberDirective, UiAccordionComponent, UiAlertMessagesOverlayService, UiAlertMessagesService, UiAvatarDirective, UiButtonDirective, UiCalendarDropdownDirective, UiCodeDirective, UiCopyButtonDirective, UiDailyCalendarDirective, UiDropdownContainerDirective, UiDropdownService, UiFieldBaseDirective, UiImageDirective, UiInputCheckboxDirective, UiInputCountryDirective, UiInputDirective, UiInputSelectDirective, UiInputSequenceDirective, UiInputTimeDirective, UiMonthlyCalendarDirective, UiPaginationDirective, UiPopupBackdropDirective, UiPopupBackdropService, UiPopupContainerDirective, UiPopupImageDirective, UiPopupInstance, UiPopupService, UiSelectButtonsDirective, UiTabsDirective, UiTimeDropdownDirective, UiValidationErrorsDirective, UiYearlyCalendarDirective, createNavigation, createUrl, createUrlTree, emptyCountry, extractParam, getAspectRatioFit, isBrowser, navigateByUrl, stringToColorGradient, stringToHslColor };
4374
4434
  //# sourceMappingURL=ibragim-dev-org-ui-forge-library.mjs.map