@skippr/live-agent-sdk 0.60.0 → 0.61.0

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.
@@ -3135,37 +3135,15 @@ function nearestScrollableContainer(element) {
3135
3135
  }
3136
3136
  return document.documentElement;
3137
3137
  }
3138
- var PAGE_SCROLLER_MAX_DEPTH = 3;
3139
- function collectShallow(element, depth, out) {
3140
- for (const child of Array.from(element.children)) {
3141
- if (child instanceof HTMLElement)
3142
- out.push(child);
3143
- if (depth > 1)
3144
- collectShallow(child, depth - 1, out);
3145
- }
3146
- }
3147
3138
  function pickPageScroller() {
3148
- const documentScroller = document.scrollingElement;
3149
- if (documentScroller && documentScroller.scrollHeight - documentScroller.clientHeight > 1) {
3150
- return documentScroller;
3139
+ const centerX = window.innerWidth / 2;
3140
+ const centerY = window.innerHeight / 2;
3141
+ for (const element of document.elementsFromPoint(centerX, centerY)) {
3142
+ if (element instanceof HTMLElement && isScrollableY(element))
3143
+ return element;
3151
3144
  }
3152
- const candidates = [];
3153
- collectShallow(document.body, PAGE_SCROLLER_MAX_DEPTH, candidates);
3154
- let largest = null;
3155
- let largestArea = 0;
3156
- for (const element of candidates) {
3157
- if (!isScrollableY(element))
3158
- continue;
3159
- const rect = element.getBoundingClientRect();
3160
- if (rect.bottom <= 0 || rect.top >= window.innerHeight)
3161
- continue;
3162
- const area = rect.width * rect.height;
3163
- if (area > largestArea) {
3164
- largestArea = area;
3165
- largest = element;
3166
- }
3167
- }
3168
- return largest ?? documentScroller ?? document.documentElement;
3145
+ const documentScroller = document.scrollingElement;
3146
+ return documentScroller ?? document.documentElement;
3169
3147
  }
3170
3148
  function gestureFor(direction) {
3171
3149
  return direction === "up" || direction === "top" ? "up" : "down";