@ibragim-dev-org/ui-forge-library 1.4.76 → 1.4.78
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.
|
@@ -1002,7 +1002,12 @@ class StableScrollDirective {
|
|
|
1002
1002
|
}
|
|
1003
1003
|
const shift = this.contentTopOf(anchor.element) - anchor.contentTop;
|
|
1004
1004
|
if (Math.abs(shift) >= 0.5) {
|
|
1005
|
-
|
|
1005
|
+
// Content removed above can leave the old position past the new end, and the browser clamps scrollTop
|
|
1006
|
+
// to it before this runs. The shift then has to be applied to the position from before that clamp,
|
|
1007
|
+
// otherwise the view lands higher by the clamped distance.
|
|
1008
|
+
const { scrollTop, scrollHeight, clientHeight } = this.el;
|
|
1009
|
+
const isClamped = scrollTop < anchor.scrollTop && scrollTop >= scrollHeight - clientHeight - 1;
|
|
1010
|
+
this.el.scrollTop = (isClamped ? anchor.scrollTop : scrollTop) + shift;
|
|
1006
1011
|
// The browser coalesces this into the next scroll event; shifting the baseline keeps it from reading as
|
|
1007
1012
|
// the user scrolling the other way, which would fire the opposite threshold
|
|
1008
1013
|
this.lastScrollTop += shift;
|
|
@@ -1027,7 +1032,7 @@ class StableScrollDirective {
|
|
|
1027
1032
|
this.wasPinnedToTop = scrollTop <= EDGE_PIN_PX;
|
|
1028
1033
|
this.wasPinnedToBottom = scrollHeight - clientHeight - scrollTop <= EDGE_PIN_PX;
|
|
1029
1034
|
const element = this.findTopVisibleCandidate();
|
|
1030
|
-
this.anchor = element ? { element, contentTop: this.contentTopOf(element) } : null;
|
|
1035
|
+
this.anchor = element ? { element, contentTop: this.contentTopOf(element), scrollTop } : null;
|
|
1031
1036
|
}
|
|
1032
1037
|
// Candidates are in document order, so the first one reaching into the viewport is found by binary search
|
|
1033
1038
|
findTopVisibleCandidate() {
|
|
@@ -2572,18 +2577,39 @@ class UiModal {
|
|
|
2572
2577
|
}
|
|
2573
2578
|
}
|
|
2574
2579
|
|
|
2580
|
+
const PULSE_KEYFRAMES = [
|
|
2581
|
+
{ transform: 'translate(0.0625rem, 0.0625rem) rotate(0deg)' },
|
|
2582
|
+
{ transform: 'translate(-0.0625rem, -0.125rem) rotate(-1deg)' },
|
|
2583
|
+
{ transform: 'translate(-0.1875rem, 0) rotate(1deg)' },
|
|
2584
|
+
{ transform: 'translate(0.1875rem, 0.125rem) rotate(0deg)' },
|
|
2585
|
+
{ transform: 'translate(0.0625rem, -0.0625rem) rotate(1deg)' },
|
|
2586
|
+
{ transform: 'translate(-0.0625rem, 0.125rem) rotate(-1deg)' },
|
|
2587
|
+
{ transform: 'translate(-0.1875rem, 0.0625rem) rotate(0deg)' },
|
|
2588
|
+
{ transform: 'translate(0.1875rem, 0.0625rem) rotate(-1deg)' },
|
|
2589
|
+
{ transform: 'translate(-0.0625rem, -0.0625rem) rotate(1deg)' },
|
|
2590
|
+
{ transform: 'translate(0.0625rem, 0.125rem) rotate(0deg)' },
|
|
2591
|
+
{ transform: 'translate(0.0625rem, -0.125rem) rotate(-1deg)' },
|
|
2592
|
+
];
|
|
2575
2593
|
class UiPopupContainerDirective {
|
|
2576
2594
|
popupInstance;
|
|
2577
2595
|
destroyRef;
|
|
2578
2596
|
popupService;
|
|
2579
2597
|
elementRef;
|
|
2580
2598
|
$isShow = signal(false, ...(ngDevMode ? [{ debugName: "$isShow" }] : []));
|
|
2581
|
-
$pulseTrigger = signal(false, ...(ngDevMode ? [{ debugName: "$pulseTrigger" }] : []));
|
|
2582
2599
|
$isHide = signal(false, ...(ngDevMode ? [{ debugName: "$isHide" }] : []));
|
|
2583
2600
|
$overflowHidden = input(true, ...(ngDevMode ? [{ debugName: "$overflowHidden" }] : []));
|
|
2584
2601
|
$shouldClose = model(false, ...(ngDevMode ? [{ debugName: "$shouldClose" }] : []));
|
|
2585
2602
|
$hasCloseButton = input(false, ...(ngDevMode ? [{ debugName: "$hasCloseButton" }] : []));
|
|
2586
2603
|
$isEnableFadeAnimation = input(true, ...(ngDevMode ? [{ debugName: "$isEnableFadeAnimation" }] : []));
|
|
2604
|
+
$hasInitialized = signal(false, ...(ngDevMode ? [{ debugName: "$hasInitialized" }] : []));
|
|
2605
|
+
fadeAnimation;
|
|
2606
|
+
pulseAnimation;
|
|
2607
|
+
$fadeState = computed(() => {
|
|
2608
|
+
if (!this.$isEnableFadeAnimation() || !this.$hasInitialized()) {
|
|
2609
|
+
return 'none';
|
|
2610
|
+
}
|
|
2611
|
+
return this.$isShow() ? 'in' : 'out';
|
|
2612
|
+
}, ...(ngDevMode ? [{ debugName: "$fadeState" }] : []));
|
|
2587
2613
|
$iconClose = model(...(ngDevMode ? [undefined, { debugName: "$iconClose" }] : []));
|
|
2588
2614
|
$animationParams = signal({
|
|
2589
2615
|
startOrigin: 'center center',
|
|
@@ -2608,6 +2634,14 @@ class UiPopupContainerDirective {
|
|
|
2608
2634
|
});
|
|
2609
2635
|
}
|
|
2610
2636
|
});
|
|
2637
|
+
effect(() => {
|
|
2638
|
+
const state = this.$fadeState();
|
|
2639
|
+
if (state === 'none' || !isBrowser()) {
|
|
2640
|
+
return;
|
|
2641
|
+
}
|
|
2642
|
+
this.fadeAnimation?.cancel();
|
|
2643
|
+
this.fadeAnimation = this.elementRef.nativeElement.animate(state === 'in' ? [{ opacity: 0 }, { opacity: 1 }] : [{ opacity: 1 }, { opacity: 0 }], { duration: 150, easing: 'linear', fill: state === 'out' ? 'forwards' : 'none' });
|
|
2644
|
+
});
|
|
2611
2645
|
effect(() => {
|
|
2612
2646
|
const params = this.$animationParams();
|
|
2613
2647
|
this.elementRef.nativeElement.style.setProperty('--start', params.start);
|
|
@@ -2634,10 +2668,7 @@ class UiPopupContainerDirective {
|
|
|
2634
2668
|
.subscribe();
|
|
2635
2669
|
this.popupInstance.triggerPulse$
|
|
2636
2670
|
.pipe(tap(() => {
|
|
2637
|
-
this
|
|
2638
|
-
asyncScheduler.schedule(() => {
|
|
2639
|
-
this.$pulseTrigger.set(false);
|
|
2640
|
-
}, 300);
|
|
2671
|
+
this.pulse();
|
|
2641
2672
|
}), takeUntilDestroyed(this.destroyRef))
|
|
2642
2673
|
.subscribe();
|
|
2643
2674
|
this.popupInstance.animationOrigin$
|
|
@@ -2655,6 +2686,7 @@ class UiPopupContainerDirective {
|
|
|
2655
2686
|
});
|
|
2656
2687
|
if (!this.popupInstance.isClosing) {
|
|
2657
2688
|
this.$isShow.set(true);
|
|
2689
|
+
this.$hasInitialized.set(true);
|
|
2658
2690
|
}
|
|
2659
2691
|
}), takeUntil(this.destroyAnimationOrigin$), takeUntilDestroyed(this.destroyRef))
|
|
2660
2692
|
.subscribe();
|
|
@@ -2683,13 +2715,30 @@ class UiPopupContainerDirective {
|
|
|
2683
2715
|
shouldClose() {
|
|
2684
2716
|
this.$shouldClose.set(true);
|
|
2685
2717
|
}
|
|
2718
|
+
pulse() {
|
|
2719
|
+
if (!isBrowser()) {
|
|
2720
|
+
return;
|
|
2721
|
+
}
|
|
2722
|
+
this.pulseAnimation?.cancel();
|
|
2723
|
+
this.pulseAnimation = this.elementRef.nativeElement.animate(PULSE_KEYFRAMES, {
|
|
2724
|
+
duration: 200,
|
|
2725
|
+
easing: 'linear',
|
|
2726
|
+
});
|
|
2727
|
+
}
|
|
2686
2728
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupContainerDirective, deps: [{ token: UiPopupInstance }, { token: i0.DestroyRef }, { token: UiModal }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2687
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: UiPopupContainerDirective, isStandalone: true, selector: "app-ui-popup-container", inputs: { $overflowHidden: { classPropertyName: "$overflowHidden", publicName: "$overflowHidden", isSignal: true, isRequired: false, transformFunction: null }, $shouldClose: { classPropertyName: "$shouldClose", publicName: "$shouldClose", isSignal: true, isRequired: false, transformFunction: null }, $hasCloseButton: { classPropertyName: "$hasCloseButton", publicName: "$hasCloseButton", isSignal: true, isRequired: false, transformFunction: null }, $isEnableFadeAnimation: { classPropertyName: "$isEnableFadeAnimation", publicName: "$isEnableFadeAnimation", isSignal: true, isRequired: false, transformFunction: null }, $iconClose: { classPropertyName: "$iconClose", publicName: "$iconClose", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { $shouldClose: "$shouldCloseChange", $iconClose: "$iconCloseChange" }, ngImport: i0 });
|
|
2729
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: UiPopupContainerDirective, isStandalone: true, selector: "app-ui-popup-container", inputs: { $overflowHidden: { classPropertyName: "$overflowHidden", publicName: "$overflowHidden", isSignal: true, isRequired: false, transformFunction: null }, $shouldClose: { classPropertyName: "$shouldClose", publicName: "$shouldClose", isSignal: true, isRequired: false, transformFunction: null }, $hasCloseButton: { classPropertyName: "$hasCloseButton", publicName: "$hasCloseButton", isSignal: true, isRequired: false, transformFunction: null }, $isEnableFadeAnimation: { classPropertyName: "$isEnableFadeAnimation", publicName: "$isEnableFadeAnimation", isSignal: true, isRequired: false, transformFunction: null }, $iconClose: { classPropertyName: "$iconClose", publicName: "$iconClose", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { $shouldClose: "$shouldCloseChange", $iconClose: "$iconCloseChange" }, host: { properties: { "style.transform": "$isHide() ? $animationParams().start : null", "style.left": "$isHide() ? $animationParams().leftStart : null", "style.top": "$isHide() ? $animationParams().topStart : null", "style.opacity": "$isHide() ? 0 : null", "style.visibility": "$isHide() ? \"hidden\" : null" } }, ngImport: i0 });
|
|
2688
2730
|
}
|
|
2689
2731
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: UiPopupContainerDirective, decorators: [{
|
|
2690
2732
|
type: Directive,
|
|
2691
2733
|
args: [{
|
|
2692
2734
|
selector: 'app-ui-popup-container',
|
|
2735
|
+
host: {
|
|
2736
|
+
'[style.transform]': '$isHide() ? $animationParams().start : null',
|
|
2737
|
+
'[style.left]': '$isHide() ? $animationParams().leftStart : null',
|
|
2738
|
+
'[style.top]': '$isHide() ? $animationParams().topStart : null',
|
|
2739
|
+
'[style.opacity]': '$isHide() ? 0 : null',
|
|
2740
|
+
'[style.visibility]': '$isHide() ? "hidden" : null',
|
|
2741
|
+
},
|
|
2693
2742
|
}]
|
|
2694
2743
|
}], ctorParameters: () => [{ type: UiPopupInstance, decorators: [{
|
|
2695
2744
|
type: Inject,
|
|
@@ -2791,7 +2840,7 @@ class UiPopupImageDirective {
|
|
|
2791
2840
|
// -----------------------------
|
|
2792
2841
|
// MOUSE WHEEL ZOOM
|
|
2793
2842
|
// -----------------------------
|
|
2794
|
-
fromEvent(
|
|
2843
|
+
fromEvent(container, 'wheel', { passive: false })
|
|
2795
2844
|
.pipe(tap((event) => {
|
|
2796
2845
|
event.preventDefault();
|
|
2797
2846
|
const rect = container.getBoundingClientRect();
|
|
@@ -2931,6 +2980,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
|
|
|
2931
2980
|
}]
|
|
2932
2981
|
}], ctorParameters: () => [{ type: i0.Type }, { type: i0.Type }] });
|
|
2933
2982
|
|
|
2983
|
+
/** Offset a new stacked popup slides in from (positive = from the right). */
|
|
2984
|
+
const STACKED_ENTER_TRANSLATE_X = '100px';
|
|
2985
|
+
/** Offset a popup slides to while it is hidden behind a newer popup (negative = to the left). */
|
|
2986
|
+
const STACKED_HIDE_TRANSLATE_X = '-100px';
|
|
2934
2987
|
class UiPopupService extends UiModal {
|
|
2935
2988
|
defaultAnimationOptions = {
|
|
2936
2989
|
startOrigin: '',
|
|
@@ -2942,6 +2995,19 @@ class UiPopupService extends UiModal {
|
|
|
2942
2995
|
topStart: '',
|
|
2943
2996
|
topEnd: '',
|
|
2944
2997
|
};
|
|
2998
|
+
/** Slide animation used by stacked popups: new ones enter from the right, hidden ones leave to the left. */
|
|
2999
|
+
stackedAnimationOptions = {
|
|
3000
|
+
startOrigin: 'center center',
|
|
3001
|
+
endOrigin: 'center center',
|
|
3002
|
+
start: `translateX(${STACKED_ENTER_TRANSLATE_X})`,
|
|
3003
|
+
end: 'translateX(0)',
|
|
3004
|
+
leftStart: '0',
|
|
3005
|
+
leftEnd: '0',
|
|
3006
|
+
topStart: '0',
|
|
3007
|
+
topEnd: '0',
|
|
3008
|
+
};
|
|
3009
|
+
/** Original animation options of popups that are currently hidden behind a newer popup. */
|
|
3010
|
+
hiddenInstanceOptions = new Map();
|
|
2945
3011
|
constructor(overlay, injector, destroyRef, router, backdropService) {
|
|
2946
3012
|
super(overlay, injector, destroyRef, router, backdropService);
|
|
2947
3013
|
}
|
|
@@ -2956,16 +3022,7 @@ class UiPopupService extends UiModal {
|
|
|
2956
3022
|
open(component, options, id, parameters) {
|
|
2957
3023
|
if (this.instances.length) {
|
|
2958
3024
|
this.closePrevious(parameters.isClosePrevious ?? false);
|
|
2959
|
-
parameters.animationOptions = {
|
|
2960
|
-
startOrigin: 'center center',
|
|
2961
|
-
endOrigin: 'center center',
|
|
2962
|
-
start: 'translateX(100%)',
|
|
2963
|
-
end: 'translateX(0)',
|
|
2964
|
-
leftStart: '0',
|
|
2965
|
-
leftEnd: '0',
|
|
2966
|
-
topStart: '0',
|
|
2967
|
-
topEnd: '0',
|
|
2968
|
-
};
|
|
3025
|
+
parameters.animationOptions = { ...this.stackedAnimationOptions };
|
|
2969
3026
|
}
|
|
2970
3027
|
this.showBackdrop(parameters.isStaticBackdrop);
|
|
2971
3028
|
const overlayRef = this.overlay.create({
|
|
@@ -2989,6 +3046,7 @@ class UiPopupService extends UiModal {
|
|
|
2989
3046
|
instance.options = this.defaultAnimationOptions;
|
|
2990
3047
|
instance.animationOrigin$.next('center');
|
|
2991
3048
|
});
|
|
3049
|
+
this.hiddenInstanceOptions.clear();
|
|
2992
3050
|
super.closeAll();
|
|
2993
3051
|
}
|
|
2994
3052
|
closeById(id) {
|
|
@@ -3005,7 +3063,14 @@ class UiPopupService extends UiModal {
|
|
|
3005
3063
|
}
|
|
3006
3064
|
applyHideToLastInstance() {
|
|
3007
3065
|
if (this.instances.length >= 1) {
|
|
3008
|
-
this.instances[this.instances.length - 1]
|
|
3066
|
+
const instance = this.instances[this.instances.length - 1];
|
|
3067
|
+
const originalOptions = this.hiddenInstanceOptions.get(instance);
|
|
3068
|
+
if (originalOptions) {
|
|
3069
|
+
instance.options = originalOptions;
|
|
3070
|
+
instance.animationOrigin$.next(instance.animationOrigin$.value);
|
|
3071
|
+
this.hiddenInstanceOptions.delete(instance);
|
|
3072
|
+
}
|
|
3073
|
+
instance.isHide$.next(false);
|
|
3009
3074
|
}
|
|
3010
3075
|
}
|
|
3011
3076
|
closePrevious(isClosePrevious) {
|
|
@@ -3013,14 +3078,17 @@ class UiPopupService extends UiModal {
|
|
|
3013
3078
|
return;
|
|
3014
3079
|
const lastIndex = this.instances.length - 1;
|
|
3015
3080
|
const lastPopupInstance = this.instances[lastIndex];
|
|
3081
|
+
this.hiddenInstanceOptions.set(lastPopupInstance, lastPopupInstance.options);
|
|
3082
|
+
lastPopupInstance.options = { ...this.stackedAnimationOptions, start: `translateX(${STACKED_HIDE_TRANSLATE_X})` };
|
|
3083
|
+
lastPopupInstance.animationOrigin$.next(lastPopupInstance.animationOrigin$.value);
|
|
3016
3084
|
lastPopupInstance.isHide$.next(true);
|
|
3017
3085
|
if (isClosePrevious) {
|
|
3018
3086
|
asyncScheduler.schedule(() => {
|
|
3019
|
-
// ensure the instance still exists
|
|
3020
3087
|
const currentIndex = this.instances.indexOf(lastPopupInstance);
|
|
3021
3088
|
if (currentIndex !== -1) {
|
|
3022
3089
|
lastPopupInstance.close();
|
|
3023
3090
|
this.instances.splice(currentIndex, 1);
|
|
3091
|
+
this.hiddenInstanceOptions.delete(lastPopupInstance);
|
|
3024
3092
|
}
|
|
3025
3093
|
}, 300);
|
|
3026
3094
|
}
|