@arsedizioni/ars-utils 21.2.200 → 21.2.201

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.
@@ -2837,10 +2837,16 @@ class ClipperPropertyBadgeComponent {
2837
2837
  this.closePopup();
2838
2838
  const popupWidth = 320;
2839
2839
  const fitsRight = event.clientX + popupWidth <= window.innerWidth;
2840
- const position = this.overlay.position().global().top(`${event.clientY}px`);
2841
- const positionStrategy = fitsRight ? position.left(`${event.clientX}px`) : position.centerHorizontally();
2840
+ const buildPositionBelow = () => {
2841
+ const s = this.overlay.position().global().top(`${event.clientY}px`);
2842
+ return fitsRight ? s.left(`${event.clientX}px`) : s.centerHorizontally();
2843
+ };
2844
+ const buildPositionAbove = () => {
2845
+ const s = this.overlay.position().global().bottom(`${window.innerHeight - event.clientY}px`);
2846
+ return fitsRight ? s.left(`${event.clientX}px`) : s.centerHorizontally();
2847
+ };
2842
2848
  const ref = this.overlay.create({
2843
- positionStrategy,
2849
+ positionStrategy: buildPositionBelow(),
2844
2850
  hasBackdrop: true,
2845
2851
  backdropClass: 'cdk-overlay-transparent-backdrop',
2846
2852
  scrollStrategy: this.overlay.scrollStrategies.close(),
@@ -2850,6 +2856,15 @@ class ClipperPropertyBadgeComponent {
2850
2856
  this.closePopup(); });
2851
2857
  ref.backdropClick().pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.closePopup());
2852
2858
  ref.attach(new TemplatePortal(this.popupTpl(), this.viewContainerRef));
2859
+ // After rendering, check if the popup overflows the bottom of the viewport and reposition upward
2860
+ setTimeout(() => {
2861
+ if (!this.overlayRef)
2862
+ return;
2863
+ const rect = ref.overlayElement.getBoundingClientRect();
2864
+ if (rect.bottom > window.innerHeight) {
2865
+ ref.updatePositionStrategy(buildPositionAbove());
2866
+ }
2867
+ });
2853
2868
  this.overlayRef = ref;
2854
2869
  }
2855
2870
  /**