@absolutejs/beacon 0.6.26 → 0.6.27

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.
package/dist/index.js CHANGED
@@ -2880,6 +2880,8 @@ var createBeacon = (options) => {
2880
2880
  let jailBurst = [];
2881
2881
  let jailScroller = null;
2882
2882
  let jailSettleTimer;
2883
+ let scrollActivityGeneration = 0;
2884
+ let jailStartingScrollGeneration = 0;
2883
2885
  const reportedScrollers = new Set;
2884
2886
  const clearJailSettle = () => {
2885
2887
  if (jailSettleTimer === undefined)
@@ -2887,6 +2889,9 @@ var createBeacon = (options) => {
2887
2889
  clearTimeout(jailSettleTimer);
2888
2890
  jailSettleTimer = undefined;
2889
2891
  };
2892
+ const onDocumentScroll = () => {
2893
+ scrollActivityGeneration += 1;
2894
+ };
2890
2895
  const onWheel = (event) => {
2891
2896
  clearJailSettle();
2892
2897
  if (event.ctrlKey || event.defaultPrevented || event.deltaY === 0) {
@@ -2911,6 +2916,9 @@ var createBeacon = (options) => {
2911
2916
  jailBurst = [];
2912
2917
  }
2913
2918
  jailBurst = jailBurst.filter((entry) => now - entry.at < SCROLL_JAIL_WINDOW_MS);
2919
+ if (jailBurst.length === 0) {
2920
+ jailStartingScrollGeneration = scrollActivityGeneration;
2921
+ }
2914
2922
  jailBurst.push({ at: now, position: scroller.scrollTop });
2915
2923
  if (jailBurst.length < SCROLL_JAIL_EVENT_COUNT)
2916
2924
  return;
@@ -2924,6 +2932,8 @@ var createBeacon = (options) => {
2924
2932
  jailSettleTimer = setTimeout(() => {
2925
2933
  jailSettleTimer = undefined;
2926
2934
  jailBurst = [];
2935
+ if (scrollActivityGeneration !== jailStartingScrollGeneration)
2936
+ return;
2927
2937
  if (!scroller.isConnected || scroller.scrollTop !== startingPosition)
2928
2938
  return;
2929
2939
  const canStillMove = scrollingDown ? scroller.scrollTop + scroller.clientHeight < scroller.scrollHeight - SCROLL_JAIL_BOUNDARY_TOLERANCE_PX : scroller.scrollTop > SCROLL_JAIL_BOUNDARY_TOLERANCE_PX;
@@ -2938,8 +2948,15 @@ var createBeacon = (options) => {
2938
2948
  emitSignal(`Scroll jail — ${descriptor} has scrollable content but never moves — ${shortUrl(location.href)}`, { signal: BEACON_SIGNAL.SCROLL_JAIL, target: descriptor });
2939
2949
  }, SCROLL_JAIL_SETTLE_MS);
2940
2950
  };
2951
+ document.addEventListener("scroll", onDocumentScroll, {
2952
+ capture: true,
2953
+ passive: true
2954
+ });
2941
2955
  document.addEventListener("wheel", onWheel, { passive: true });
2942
2956
  cleanups.push(() => {
2957
+ document.removeEventListener("scroll", onDocumentScroll, {
2958
+ capture: true
2959
+ });
2943
2960
  document.removeEventListener("wheel", onWheel);
2944
2961
  clearJailSettle();
2945
2962
  });
@@ -3912,5 +3929,5 @@ export {
3912
3929
  BEACON_ATTRIBUTE
3913
3930
  };
3914
3931
 
3915
- //# debugId=5144B9A028EDFBDF64756E2164756E21
3932
+ //# debugId=DBDAEE5BB5F38AFA64756E2164756E21
3916
3933
  //# sourceMappingURL=index.js.map