framer-motion 12.29.2 → 12.29.3
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/cjs/index.js +23 -11
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/components/Reorder/utils/auto-scroll.mjs +23 -11
- package/dist/es/components/Reorder/utils/auto-scroll.mjs.map +1 -1
- package/dist/framer-motion.dev.js +23 -11
- package/dist/framer-motion.js +1 -1
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -843,7 +843,9 @@ function resetAutoScrollState() {
|
|
|
843
843
|
function isScrollableElement(element, axis) {
|
|
844
844
|
const style = getComputedStyle(element);
|
|
845
845
|
const overflow = axis === "x" ? style.overflowX : style.overflowY;
|
|
846
|
-
|
|
846
|
+
const isDocumentScroll = element === document.body ||
|
|
847
|
+
element === document.documentElement;
|
|
848
|
+
return overflowStyles.has(overflow) || isDocumentScroll;
|
|
847
849
|
}
|
|
848
850
|
function findScrollableAncestor(element, axis) {
|
|
849
851
|
let current = element?.parentElement;
|
|
@@ -857,8 +859,8 @@ function findScrollableAncestor(element, axis) {
|
|
|
857
859
|
}
|
|
858
860
|
function getScrollAmount(pointerPosition, scrollElement, axis) {
|
|
859
861
|
const rect = scrollElement.getBoundingClientRect();
|
|
860
|
-
const start = axis === "x" ? rect.left : rect.top;
|
|
861
|
-
const end = axis === "x" ? rect.right : rect.bottom;
|
|
862
|
+
const start = axis === "x" ? Math.max(0, rect.left) : Math.max(0, rect.top);
|
|
863
|
+
const end = axis === "x" ? Math.min(window.innerWidth, rect.right) : Math.min(window.innerHeight, rect.bottom);
|
|
862
864
|
const distanceFromStart = pointerPosition - start;
|
|
863
865
|
const distanceFromEnd = end - pointerPosition;
|
|
864
866
|
if (distanceFromStart < threshold) {
|
|
@@ -891,6 +893,8 @@ function autoScrollIfNeeded(groupElement, pointerPosition, axis, velocity) {
|
|
|
891
893
|
return;
|
|
892
894
|
}
|
|
893
895
|
const currentActiveEdge = activeScrollEdge.get(scrollableAncestor);
|
|
896
|
+
const isDocumentScroll = scrollableAncestor === document.body ||
|
|
897
|
+
scrollableAncestor === document.documentElement;
|
|
894
898
|
// If not currently scrolling this edge, check velocity to see if we should start
|
|
895
899
|
if (currentActiveEdge !== edge) {
|
|
896
900
|
// Only start scrolling if velocity is towards the edge
|
|
@@ -902,27 +906,35 @@ function autoScrollIfNeeded(groupElement, pointerPosition, axis, velocity) {
|
|
|
902
906
|
activeScrollEdge.set(scrollableAncestor, edge);
|
|
903
907
|
// Record initial scroll limit (prevents infinite scroll)
|
|
904
908
|
const maxScroll = axis === "x"
|
|
905
|
-
? scrollableAncestor.scrollWidth -
|
|
906
|
-
|
|
907
|
-
: scrollableAncestor.scrollHeight -
|
|
908
|
-
scrollableAncestor.clientHeight;
|
|
909
|
+
? scrollableAncestor.scrollWidth - (isDocumentScroll ? window.innerWidth : scrollableAncestor.clientWidth)
|
|
910
|
+
: scrollableAncestor.scrollHeight - (isDocumentScroll ? window.innerHeight : scrollableAncestor.clientHeight);
|
|
909
911
|
initialScrollLimits.set(scrollableAncestor, maxScroll);
|
|
910
912
|
}
|
|
911
913
|
// Cap scrolling at initial limit (prevents infinite scroll)
|
|
912
914
|
if (scrollAmount > 0) {
|
|
913
915
|
const initialLimit = initialScrollLimits.get(scrollableAncestor);
|
|
914
916
|
const currentScroll = axis === "x"
|
|
915
|
-
? scrollableAncestor.scrollLeft
|
|
916
|
-
: scrollableAncestor.scrollTop;
|
|
917
|
+
? (isDocumentScroll ? window.scrollX : scrollableAncestor.scrollLeft)
|
|
918
|
+
: (isDocumentScroll ? window.scrollY : scrollableAncestor.scrollTop);
|
|
917
919
|
if (currentScroll >= initialLimit)
|
|
918
920
|
return;
|
|
919
921
|
}
|
|
920
922
|
// Apply scroll
|
|
921
923
|
if (axis === "x") {
|
|
922
|
-
|
|
924
|
+
if (isDocumentScroll) {
|
|
925
|
+
window.scrollBy({ left: scrollAmount });
|
|
926
|
+
}
|
|
927
|
+
else {
|
|
928
|
+
scrollableAncestor.scrollLeft += scrollAmount;
|
|
929
|
+
}
|
|
923
930
|
}
|
|
924
931
|
else {
|
|
925
|
-
|
|
932
|
+
if (isDocumentScroll) {
|
|
933
|
+
window.scrollBy({ top: scrollAmount });
|
|
934
|
+
}
|
|
935
|
+
else {
|
|
936
|
+
scrollableAncestor.scrollTop += scrollAmount;
|
|
937
|
+
}
|
|
926
938
|
}
|
|
927
939
|
}
|
|
928
940
|
|