releasebird-javascript-sdk 1.0.76 → 1.0.77

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.
@@ -53,7 +53,8 @@ export class RbirdFormManager {
53
53
  const state = sessionManager.getState();
54
54
 
55
55
  const http = new XMLHttpRequest();
56
- http.open("GET", `${API}/ewidget/forms/${formId}`);
56
+ const url = `${API}/ewidget/forms/${formId}`;
57
+ http.open("GET", url);
57
58
  http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
58
59
  http.setRequestHeader("apiKey", this.apiKey);
59
60
 
@@ -552,6 +552,40 @@ export default class RbirdWebsiteWidget {
552
552
  });
553
553
 
554
554
  this.messageBubblesContainer.style.display = 'flex';
555
+
556
+ // Position bubbles so they don't overflow screen edges
557
+ this.positionMessageBubbles();
558
+ }
559
+
560
+ /**
561
+ * Position message bubbles container to stay within viewport bounds
562
+ */
563
+ positionMessageBubbles() {
564
+ if (!this.messageBubblesContainer || !this.websiteWidget) return;
565
+
566
+ const buttonRect = this.websiteWidget.getBoundingClientRect();
567
+ const containerWidth = 320; // max-width from CSS
568
+ const padding = 10; // minimum distance from screen edge
569
+ const gap = 20; // gap between button and bubbles
570
+
571
+ // Calculate vertical position (above the button)
572
+ const bottomFromViewport = window.innerHeight - buttonRect.top + gap;
573
+ this.messageBubblesContainer.style.bottom = `${bottomFromViewport}px`;
574
+
575
+ // Calculate horizontal position
576
+ // Try to center on the button first
577
+ let leftPosition = buttonRect.left + (buttonRect.width / 2) - (containerWidth / 2);
578
+
579
+ // Constrain to viewport bounds
580
+ const minLeft = padding;
581
+ const maxLeft = window.innerWidth - containerWidth - padding;
582
+
583
+ // Clamp the position
584
+ leftPosition = Math.max(minLeft, Math.min(leftPosition, maxLeft));
585
+
586
+ // Apply position
587
+ this.messageBubblesContainer.style.left = `${leftPosition}px`;
588
+ this.messageBubblesContainer.style.right = 'unset';
555
589
  }
556
590
 
557
591
  /**
@@ -824,10 +858,7 @@ export default class RbirdWebsiteWidget {
824
858
 
825
859
  // Update message bubbles container position
826
860
  if (this.messageBubblesContainer) {
827
- const buttonRect = this.websiteWidget.getBoundingClientRect();
828
- this.messageBubblesContainer.style.left = `${buttonRect.left}px`;
829
- this.messageBubblesContainer.style.right = 'unset';
830
- this.messageBubblesContainer.style.bottom = `${window.innerHeight - buttonRect.top + 20}px`;
861
+ this.positionMessageBubbles();
831
862
  }
832
863
  }
833
864
 
@@ -909,9 +940,7 @@ export default class RbirdWebsiteWidget {
909
940
 
910
941
  // Update message bubbles container position
911
942
  if (this.messageBubblesContainer) {
912
- this.messageBubblesContainer.style.left = `${buttonRect.left}px`;
913
- this.messageBubblesContainer.style.right = 'unset';
914
- this.messageBubblesContainer.style.bottom = `${window.innerHeight - buttonRect.top + 20}px`;
943
+ this.positionMessageBubbles();
915
944
  }
916
945
  }
917
946