@skrillex1224/playwright-toolkit 2.1.28 → 2.1.29
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.cjs +43 -8
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +43 -8
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -713,16 +713,26 @@ var Humanize = {
|
|
|
713
713
|
while (current) {
|
|
714
714
|
if (isScrollable(current)) {
|
|
715
715
|
const crect = current.getBoundingClientRect();
|
|
716
|
-
if (rect.top < crect.top || rect.bottom > crect.bottom) {
|
|
716
|
+
if (rect.top < crect.top + 2 || rect.bottom > crect.bottom - 2) {
|
|
717
717
|
return true;
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
720
|
current = current.parentElement;
|
|
721
721
|
}
|
|
722
|
+
const cx = rect.left + rect.width / 2;
|
|
723
|
+
const cy = rect.top + rect.height / 2;
|
|
724
|
+
if (cx < 0 || cx > window.innerWidth || cy < 0 || cy > window.innerHeight) return true;
|
|
725
|
+
const pointElement = document.elementFromPoint(cx, cy);
|
|
726
|
+
if (pointElement) {
|
|
727
|
+
if (el.contains(pointElement) || pointElement.contains(el)) {
|
|
728
|
+
return false;
|
|
729
|
+
}
|
|
730
|
+
return true;
|
|
731
|
+
}
|
|
722
732
|
return false;
|
|
723
733
|
});
|
|
724
734
|
if (!needsScroll) {
|
|
725
|
-
logger4.debug("humanScroll", "Element already in view");
|
|
735
|
+
logger4.debug("humanScroll", "Element already in view (and unobstructed)");
|
|
726
736
|
return { element, didScroll: false, restore: async () => {
|
|
727
737
|
} };
|
|
728
738
|
}
|
|
@@ -771,9 +781,21 @@ var Humanize = {
|
|
|
771
781
|
}
|
|
772
782
|
const scrollingElement = document.scrollingElement || document.documentElement;
|
|
773
783
|
if (scrollingElement) scrollables.push(scrollingElement);
|
|
784
|
+
const cx = rect.left + rect.width / 2;
|
|
785
|
+
const cy = rect.top + rect.height / 2;
|
|
786
|
+
const viewH = window.innerHeight;
|
|
787
|
+
let isObstructed = false;
|
|
788
|
+
if (cy < 0 || cy > viewH) {
|
|
789
|
+
isObstructed = true;
|
|
790
|
+
} else {
|
|
791
|
+
const pointElement = document.elementFromPoint(cx, cy);
|
|
792
|
+
if (pointElement && !el.contains(pointElement) && !pointElement.contains(el)) {
|
|
793
|
+
isObstructed = true;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
774
796
|
let target2 = null;
|
|
775
797
|
for (const container of scrollables) {
|
|
776
|
-
const crect = container === scrollingElement ? { top: 0, bottom:
|
|
798
|
+
const crect = container === scrollingElement ? { top: 0, bottom: viewH } : container.getBoundingClientRect();
|
|
777
799
|
if (rect.top < crect.top + 2) {
|
|
778
800
|
target2 = { container, direction: -1 };
|
|
779
801
|
break;
|
|
@@ -782,26 +804,39 @@ var Humanize = {
|
|
|
782
804
|
target2 = { container, direction: 1 };
|
|
783
805
|
break;
|
|
784
806
|
}
|
|
807
|
+
if (isObstructed) {
|
|
808
|
+
const containerCenter = (crect.top + crect.bottom) / 2;
|
|
809
|
+
const elementCenter = (rect.top + rect.bottom) / 2;
|
|
810
|
+
const forceDirection = elementCenter > containerCenter ? 1 : -1;
|
|
811
|
+
const canScroll = forceDirection === 1 ? container.scrollTop < container.scrollHeight - container.clientHeight : container.scrollTop > 0;
|
|
812
|
+
if (canScroll) {
|
|
813
|
+
target2 = { container, direction: forceDirection };
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
785
817
|
}
|
|
786
818
|
if (!target2) {
|
|
787
|
-
return { moved: false, inView:
|
|
819
|
+
return { moved: false, inView: !isObstructed };
|
|
788
820
|
}
|
|
789
821
|
const maxScroll = target2.container.scrollHeight - target2.container.clientHeight;
|
|
790
822
|
if (maxScroll <= 0) {
|
|
791
|
-
return { moved: false, inView:
|
|
823
|
+
return { moved: false, inView: !isObstructed };
|
|
792
824
|
}
|
|
793
825
|
const before = target2.container.scrollTop;
|
|
794
826
|
let next = before + target2.direction * stepPx;
|
|
795
827
|
if (next < 0) next = 0;
|
|
796
828
|
if (next > maxScroll) next = maxScroll;
|
|
797
|
-
if (next
|
|
798
|
-
return { moved: false, inView:
|
|
829
|
+
if (Math.abs(next - before) < 1) {
|
|
830
|
+
return { moved: false, inView: !isObstructed };
|
|
799
831
|
}
|
|
800
832
|
target2.container.scrollTop = next;
|
|
801
833
|
return { moved: true, inView: false };
|
|
802
834
|
}, step);
|
|
803
835
|
if (result.inView) break;
|
|
804
|
-
if (!result.moved)
|
|
836
|
+
if (!result.moved && !result.inView) {
|
|
837
|
+
logger4.warn("humanScroll", "Stuck: cannot scroll further but element still obstructed/hidden");
|
|
838
|
+
break;
|
|
839
|
+
}
|
|
805
840
|
await (0, import_delay2.default)(this.jitterMs(120, 0.4));
|
|
806
841
|
}
|
|
807
842
|
const restore = async () => {
|