@byeolnaerim/flex-layout 0.0.8 → 0.0.10
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/flex-layout/components/FlexLayout.cjs +1 -76
- package/dist/flex-layout/components/FlexLayout.js +1 -70
- package/dist/flex-layout/components/FlexLayoutContainer.cjs +1 -196
- package/dist/flex-layout/components/FlexLayoutContainer.js +1 -189
- package/dist/flex-layout/components/FlexLayoutIFramePane.cjs +1 -0
- package/dist/flex-layout/components/FlexLayoutIFramePane.d.ts +4 -0
- package/dist/flex-layout/components/FlexLayoutIFramePane.js +1 -0
- package/dist/flex-layout/components/FlexLayoutResizePanel.cjs +1 -192
- package/dist/flex-layout/components/FlexLayoutResizePanel.d.ts +1 -1
- package/dist/flex-layout/components/FlexLayoutResizePanel.js +1 -186
- package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs +1 -1211
- package/dist/flex-layout/components/FlexLayoutSplitScreen.js +1 -1197
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs +1 -339
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.d.ts +1 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js +1 -333
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs +1 -32
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js +1 -25
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs +1 -40
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js +1 -34
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs +1 -30
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js +1 -24
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs +1 -109
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js +1 -103
- package/dist/flex-layout/components/FlexLayoutStickyBox.cjs +1 -226
- package/dist/flex-layout/components/FlexLayoutStickyBox.d.ts +1 -0
- package/dist/flex-layout/components/FlexLayoutStickyBox.js +1 -224
- package/dist/flex-layout/components/index.cjs +1 -52
- package/dist/flex-layout/components/index.js +1 -9
- package/dist/flex-layout/hooks/index.cjs +1 -21
- package/dist/flex-layout/hooks/index.js +1 -4
- package/dist/flex-layout/hooks/useDrag.cjs +1 -232
- package/dist/flex-layout/hooks/useDrag.d.ts +20 -0
- package/dist/flex-layout/hooks/useDrag.js +1 -219
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs +1 -118
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js +1 -116
- package/dist/flex-layout/hooks/useListPaging.cjs +1 -179
- package/dist/flex-layout/hooks/useListPaging.js +1 -175
- package/dist/flex-layout/hooks/useSizes.cjs +1 -104
- package/dist/flex-layout/hooks/useSizes.js +1 -101
- package/dist/flex-layout/index.cjs +1 -42
- package/dist/flex-layout/index.js +1 -7
- package/dist/flex-layout/providers/FlexLayoutContext.cjs +1 -26
- package/dist/flex-layout/providers/FlexLayoutContext.js +1 -23
- package/dist/flex-layout/providers/FlexLayoutHooks.cjs +1 -247
- package/dist/flex-layout/providers/FlexLayoutHooks.d.ts +5 -1
- package/dist/flex-layout/providers/FlexLayoutHooks.js +1 -238
- package/dist/flex-layout/providers/index.cjs +1 -14
- package/dist/flex-layout/providers/index.js +1 -3
- package/dist/flex-layout/store/FlexLayoutContainerStore.cjs +1 -203
- package/dist/flex-layout/store/FlexLayoutContainerStore.d.ts +1 -0
- package/dist/flex-layout/store/FlexLayoutContainerStore.js +1 -181
- package/dist/flex-layout/store/index.cjs +1 -14
- package/dist/flex-layout/store/index.js +1 -3
- package/dist/flex-layout/styles/FlexLayout.module.css +473 -416
- package/dist/flex-layout/types/FlexDirectionTypes.cjs +1 -4
- package/dist/flex-layout/types/FlexDirectionTypes.js +0 -3
- package/dist/flex-layout/types/FlexLayoutTypes.cjs +1 -4
- package/dist/flex-layout/types/FlexLayoutTypes.d.ts +1 -3
- package/dist/flex-layout/types/FlexLayoutTypes.js +0 -3
- package/dist/flex-layout/utils/FlexLayoutUtils.cjs +1 -208
- package/dist/flex-layout/utils/FlexLayoutUtils.d.ts +4 -4
- package/dist/flex-layout/utils/FlexLayoutUtils.js +1 -196
- package/dist/flex-layout/utils/index.cjs +1 -14
- package/dist/flex-layout/utils/index.js +1 -3
- package/dist/index.cjs +1 -14
- package/dist/index.js +1 -3
- package/dist/types/css.d.cjs +1 -4
- package/dist/types/css.d.js +0 -3
- package/package.json +116 -109
- package/dist/flex-layout/components/FlexLayout.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayout.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutContainer.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutContainer.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutResizePanel.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutResizePanel.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreen.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreen.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBox.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxContainer.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxItem.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenDragBoxTitleMore.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutSplitScreenScrollBox.js.map +0 -1
- package/dist/flex-layout/components/FlexLayoutStickyBox.cjs.map +0 -1
- package/dist/flex-layout/components/FlexLayoutStickyBox.js.map +0 -1
- package/dist/flex-layout/components/index.cjs.map +0 -1
- package/dist/flex-layout/components/index.js.map +0 -1
- package/dist/flex-layout/hooks/index.cjs.map +0 -1
- package/dist/flex-layout/hooks/index.js.map +0 -1
- package/dist/flex-layout/hooks/useDrag.cjs.map +0 -1
- package/dist/flex-layout/hooks/useDrag.js.map +0 -1
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.cjs.map +0 -1
- package/dist/flex-layout/hooks/useFlexLayoutSplitScreen.js.map +0 -1
- package/dist/flex-layout/hooks/useListPaging.cjs.map +0 -1
- package/dist/flex-layout/hooks/useListPaging.js.map +0 -1
- package/dist/flex-layout/hooks/useSizes.cjs.map +0 -1
- package/dist/flex-layout/hooks/useSizes.js.map +0 -1
- package/dist/flex-layout/index.cjs.map +0 -1
- package/dist/flex-layout/index.js.map +0 -1
- package/dist/flex-layout/providers/FlexLayoutContext.cjs.map +0 -1
- package/dist/flex-layout/providers/FlexLayoutContext.js.map +0 -1
- package/dist/flex-layout/providers/FlexLayoutHooks.cjs.map +0 -1
- package/dist/flex-layout/providers/FlexLayoutHooks.js.map +0 -1
- package/dist/flex-layout/providers/index.cjs.map +0 -1
- package/dist/flex-layout/providers/index.js.map +0 -1
- package/dist/flex-layout/store/FlexLayoutContainerStore.cjs.map +0 -1
- package/dist/flex-layout/store/FlexLayoutContainerStore.js.map +0 -1
- package/dist/flex-layout/store/index.cjs.map +0 -1
- package/dist/flex-layout/store/index.js.map +0 -1
- package/dist/flex-layout/types/FlexDirectionTypes.cjs.map +0 -1
- package/dist/flex-layout/types/FlexDirectionTypes.js.map +0 -1
- package/dist/flex-layout/types/FlexLayoutTypes.cjs.map +0 -1
- package/dist/flex-layout/types/FlexLayoutTypes.js.map +0 -1
- package/dist/flex-layout/utils/FlexLayoutUtils.cjs.map +0 -1
- package/dist/flex-layout/utils/FlexLayoutUtils.js.map +0 -1
- package/dist/flex-layout/utils/index.cjs.map +0 -1
- package/dist/flex-layout/utils/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types/css.d.cjs.map +0 -1
- package/dist/types/css.d.js.map +0 -1
|
@@ -1,103 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { memo, useRef, useState, useEffect } from 'react';
|
|
3
|
-
import { Subject, fromEvent } from 'rxjs';
|
|
4
|
-
import { throttleTime, take } from 'rxjs/operators';
|
|
5
|
-
import { setScrollPosition, getScrollPosition, removeScrollPosition } from '../store/FlexLayoutContainerStore';
|
|
6
|
-
import listScroll from '../styles/listScroll.module.css';
|
|
7
|
-
|
|
8
|
-
const FlexLayoutSplitScreenScrollBox = ({
|
|
9
|
-
className,
|
|
10
|
-
children,
|
|
11
|
-
keyName,
|
|
12
|
-
direction,
|
|
13
|
-
isDefaultScrollStyle = false,
|
|
14
|
-
...props
|
|
15
|
-
}) => {
|
|
16
|
-
const scrollRef = useRef(null);
|
|
17
|
-
const [isMouseDown, setIsMouseDown] = useState(false);
|
|
18
|
-
const scrollEventSubject = useRef(new Subject());
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
const mouseUpSubscribe = fromEvent(
|
|
21
|
-
window,
|
|
22
|
-
"mouseup"
|
|
23
|
-
).subscribe(() => {
|
|
24
|
-
setIsMouseDown(false);
|
|
25
|
-
});
|
|
26
|
-
const scrollEventSubscribe = scrollEventSubject.current.pipe(throttleTime(70)).subscribe((position) => {
|
|
27
|
-
setScrollPosition(keyName, position);
|
|
28
|
-
});
|
|
29
|
-
const scrollSubscribe = getScrollPosition(keyName).pipe(take(1)).subscribe((position) => {
|
|
30
|
-
if (scrollRef.current && position) {
|
|
31
|
-
scrollRef.current.scrollLeft = position.x;
|
|
32
|
-
scrollRef.current.scrollTop = position.y;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
return () => {
|
|
36
|
-
removeScrollPosition(keyName);
|
|
37
|
-
mouseUpSubscribe.unsubscribe();
|
|
38
|
-
scrollSubscribe.unsubscribe();
|
|
39
|
-
scrollEventSubscribe.unsubscribe();
|
|
40
|
-
};
|
|
41
|
-
}, [keyName]);
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (!scrollRef.current) return;
|
|
44
|
-
let animationFrameId = null;
|
|
45
|
-
const handleWheel = (event) => {
|
|
46
|
-
if (!scrollRef.current || direction !== "x") return;
|
|
47
|
-
if (scrollRef.current.matches(":hover")) {
|
|
48
|
-
event.preventDefault();
|
|
49
|
-
const { deltaY } = event;
|
|
50
|
-
const newScrollLeft = scrollRef.current.scrollLeft + deltaY;
|
|
51
|
-
if (animationFrameId) {
|
|
52
|
-
cancelAnimationFrame(animationFrameId);
|
|
53
|
-
}
|
|
54
|
-
animationFrameId = requestAnimationFrame(() => {
|
|
55
|
-
scrollRef.current.scrollLeft = newScrollLeft;
|
|
56
|
-
scrollEventSubject.current.next({
|
|
57
|
-
x: newScrollLeft,
|
|
58
|
-
y: scrollRef.current.scrollTop
|
|
59
|
-
});
|
|
60
|
-
animationFrameId = null;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
scrollRef.current.addEventListener("wheel", handleWheel, {
|
|
65
|
-
passive: false
|
|
66
|
-
});
|
|
67
|
-
return () => {
|
|
68
|
-
scrollRef.current?.removeEventListener("wheel", handleWheel);
|
|
69
|
-
};
|
|
70
|
-
}, []);
|
|
71
|
-
return /* @__PURE__ */ jsx(
|
|
72
|
-
"div",
|
|
73
|
-
{
|
|
74
|
-
ref: scrollRef,
|
|
75
|
-
onMouseUp: () => setIsMouseDown(false),
|
|
76
|
-
onMouseDown: () => setIsMouseDown(true),
|
|
77
|
-
onMouseMove: (event) => {
|
|
78
|
-
if (!scrollRef.current || !isMouseDown || direction !== "x")
|
|
79
|
-
return;
|
|
80
|
-
scrollRef.current.scrollLeft += event.movementX * -1;
|
|
81
|
-
scrollEventSubject.current.next({
|
|
82
|
-
x: scrollRef.current.scrollLeft,
|
|
83
|
-
y: scrollRef.current.scrollTop
|
|
84
|
-
});
|
|
85
|
-
},
|
|
86
|
-
onScroll: () => {
|
|
87
|
-
if (!scrollRef.current) return;
|
|
88
|
-
scrollEventSubject.current.next({
|
|
89
|
-
x: scrollRef.current.scrollLeft,
|
|
90
|
-
y: scrollRef.current.scrollTop
|
|
91
|
-
});
|
|
92
|
-
},
|
|
93
|
-
className: `${className || ""} ${isDefaultScrollStyle ? listScroll["default-scroll"] : listScroll["list-scroll"]} ${direction ? listScroll[direction] : ""}`,
|
|
94
|
-
...props,
|
|
95
|
-
children
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
};
|
|
99
|
-
var FlexLayoutSplitScreenScrollBox_default = memo(FlexLayoutSplitScreenScrollBox);
|
|
100
|
-
|
|
101
|
-
export { FlexLayoutSplitScreenScrollBox_default as default };
|
|
102
|
-
//# sourceMappingURL=FlexLayoutSplitScreenScrollBox.js.map
|
|
103
|
-
//# sourceMappingURL=FlexLayoutSplitScreenScrollBox.js.map
|
|
1
|
+
"use client";import{jsx as D}from"react/jsx-runtime";import{memo as L,useEffect as a,useRef as m,useState as M}from"react";import{fromEvent as E,Subject as d}from"rxjs";import{take as w,throttleTime as F}from"rxjs/operators";import{getScrollPosition as T,removeScrollPosition as h,setScrollPosition as y}from"../store/FlexLayoutContainerStore";import i from"../styles/listScroll.module.css";const P=({className:S,children:b,keyName:l,direction:o,isDefaultScrollStyle:p=!1,...x})=>{const e=m(null),[v,u]=M(!1),n=m(new d);return a(()=>{const r=E(window,"mouseup").subscribe(()=>{u(!1)}),s=n.current.pipe(F(70)).subscribe(t=>{y(l,t)}),c=T(l).pipe(w(1)).subscribe(t=>{e.current&&t&&(e.current.scrollLeft=t.x,e.current.scrollTop=t.y)});return()=>{h(l),r.unsubscribe(),c.unsubscribe(),s.unsubscribe()}},[l]),a(()=>{if(!e.current)return;let r=null;const s=c=>{if(!(!e.current||o!=="x")&&e.current.matches(":hover")){c.preventDefault();const{deltaY:t}=c,f=e.current.scrollLeft+t;r&&cancelAnimationFrame(r),r=requestAnimationFrame(()=>{e.current.scrollLeft=f,n.current.next({x:f,y:e.current.scrollTop}),r=null})}};return e.current.addEventListener("wheel",s,{passive:!1}),()=>{e.current?.removeEventListener("wheel",s)}},[]),D("div",{ref:e,onMouseUp:()=>u(!1),onMouseDown:()=>u(!0),onMouseMove:r=>{!e.current||!v||o!=="x"||(e.current.scrollLeft+=r.movementX*-1,n.current.next({x:e.current.scrollLeft,y:e.current.scrollTop}))},onScroll:()=>{e.current&&n.current.next({x:e.current.scrollLeft,y:e.current.scrollTop})},className:`${S||""} ${p?i["default-scroll"]:i["list-scroll"]} ${o?i[o]:""}`,...x,children:b})};var U=L(P);export{U as default};
|
|
@@ -1,226 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var react = require('react');
|
|
5
|
-
|
|
6
|
-
function clamp(n, min, max) {
|
|
7
|
-
return Math.max(min, Math.min(max, n));
|
|
8
|
-
}
|
|
9
|
-
function pickDefaultScrollRoot() {
|
|
10
|
-
if (typeof document === "undefined") return null;
|
|
11
|
-
let el = document.body;
|
|
12
|
-
while (el && el !== document.documentElement && el !== document.body) {
|
|
13
|
-
const style = getComputedStyle(el);
|
|
14
|
-
const oy = style.overflowY;
|
|
15
|
-
const ox = style.overflowX;
|
|
16
|
-
const scrollable = oy === "auto" || oy === "scroll" || ox === "auto" || ox === "scroll";
|
|
17
|
-
if (scrollable) return el;
|
|
18
|
-
el = el.parentElement;
|
|
19
|
-
}
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
function isVerticalScroll(root) {
|
|
23
|
-
if (typeof window == "undefined") return true;
|
|
24
|
-
if (!root) {
|
|
25
|
-
return document.documentElement.scrollHeight > window.innerHeight + 1;
|
|
26
|
-
}
|
|
27
|
-
const el = root;
|
|
28
|
-
return el.scrollHeight > el.clientHeight + 1;
|
|
29
|
-
}
|
|
30
|
-
const dpr = typeof window != "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
31
|
-
function quantizeToDevicePixel(n) {
|
|
32
|
-
return Math.round(n * dpr) / dpr;
|
|
33
|
-
}
|
|
34
|
-
const FlexLayoutStickyBox = ({
|
|
35
|
-
edge = "auto",
|
|
36
|
-
offset = 16,
|
|
37
|
-
scrollRoot = null,
|
|
38
|
-
debug = false,
|
|
39
|
-
children,
|
|
40
|
-
style,
|
|
41
|
-
className,
|
|
42
|
-
onTranslateChange = () => {
|
|
43
|
-
},
|
|
44
|
-
...rest
|
|
45
|
-
}) => {
|
|
46
|
-
const offsetRef = react.useRef(offset);
|
|
47
|
-
const rootRef = react.useRef(null);
|
|
48
|
-
const contentRef = react.useRef(null);
|
|
49
|
-
const mutatingRef = react.useRef(false);
|
|
50
|
-
const lastOffsetRef = react.useRef(0);
|
|
51
|
-
const [resolvedEdge, setResolvedEdge] = react.useState("top");
|
|
52
|
-
const rafId = react.useRef(null);
|
|
53
|
-
const [contentDynamicStyle, setContentDynamicStyle] = react.useState({});
|
|
54
|
-
react.useEffect(() => {
|
|
55
|
-
setContentDynamicStyle({
|
|
56
|
-
willChange: "transform",
|
|
57
|
-
transition: "transform 50ms linear"
|
|
58
|
-
});
|
|
59
|
-
}, []);
|
|
60
|
-
react.useEffect(() => {
|
|
61
|
-
offsetRef.current = offset;
|
|
62
|
-
scheduleUpdate();
|
|
63
|
-
}, [offset]);
|
|
64
|
-
const [ioRoot, setIoRoot] = react.useState(null);
|
|
65
|
-
react.useEffect(() => {
|
|
66
|
-
const root = scrollRoot ?? pickDefaultScrollRoot();
|
|
67
|
-
setResolvedEdge(
|
|
68
|
-
edge === "auto" ? isVerticalScroll(root) ? "top" : "left" : edge
|
|
69
|
-
);
|
|
70
|
-
setIoRoot(root);
|
|
71
|
-
}, [edge, scrollRoot]);
|
|
72
|
-
react.useEffect(() => {
|
|
73
|
-
if (edge !== "auto") {
|
|
74
|
-
setResolvedEdge(edge);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const vertical = isVerticalScroll(ioRoot);
|
|
78
|
-
setResolvedEdge(vertical ? "top" : "left");
|
|
79
|
-
}, [edge, ioRoot]);
|
|
80
|
-
react.useEffect(() => {
|
|
81
|
-
}, []);
|
|
82
|
-
const scheduleUpdate = () => {
|
|
83
|
-
if (rafId.current != null) return;
|
|
84
|
-
rafId.current = requestAnimationFrame(() => {
|
|
85
|
-
rafId.current = null;
|
|
86
|
-
doUpdate();
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
const doUpdate = () => {
|
|
90
|
-
if (mutatingRef.current) return;
|
|
91
|
-
mutatingRef.current = true;
|
|
92
|
-
const rootEl = rootRef.current;
|
|
93
|
-
const contentEl = contentRef.current;
|
|
94
|
-
if (!rootEl || !contentEl) {
|
|
95
|
-
mutatingRef.current = false;
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const parentEl = rootEl.parentElement;
|
|
99
|
-
if (!parentEl) {
|
|
100
|
-
mutatingRef.current = false;
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
const rootBounds = ioRoot && "getBoundingClientRect" in ioRoot ? ioRoot.getBoundingClientRect() : new DOMRect(0, 0, window.innerWidth, window.innerHeight);
|
|
104
|
-
const parentRect = parentEl.getBoundingClientRect();
|
|
105
|
-
const contentRect = contentEl.getBoundingClientRect();
|
|
106
|
-
let newOffset = 0;
|
|
107
|
-
if (resolvedEdge === "top" || resolvedEdge === "bottom") {
|
|
108
|
-
const maxTranslate = Math.max(
|
|
109
|
-
0,
|
|
110
|
-
parentRect.height - contentRect.height
|
|
111
|
-
);
|
|
112
|
-
let desiredTop = 0;
|
|
113
|
-
if (resolvedEdge === "top") {
|
|
114
|
-
desiredTop = rootBounds.top + offsetRef.current - parentRect.top;
|
|
115
|
-
} else {
|
|
116
|
-
const targetBottomFromParentTop = Math.min(
|
|
117
|
-
parentRect.bottom,
|
|
118
|
-
rootBounds.bottom - offsetRef.current
|
|
119
|
-
) - parentRect.top;
|
|
120
|
-
desiredTop = targetBottomFromParentTop - contentRect.height;
|
|
121
|
-
}
|
|
122
|
-
newOffset = clamp(desiredTop, 0, maxTranslate);
|
|
123
|
-
} else {
|
|
124
|
-
const maxTranslate = Math.max(
|
|
125
|
-
0,
|
|
126
|
-
parentRect.width - contentRect.width
|
|
127
|
-
);
|
|
128
|
-
let desiredLeft = 0;
|
|
129
|
-
if (resolvedEdge === "left") {
|
|
130
|
-
desiredLeft = rootBounds.left + offsetRef.current - parentRect.left;
|
|
131
|
-
} else {
|
|
132
|
-
const targetRightFromParentLeft = Math.min(
|
|
133
|
-
parentRect.right,
|
|
134
|
-
rootBounds.right - offsetRef.current
|
|
135
|
-
) - parentRect.left;
|
|
136
|
-
desiredLeft = targetRightFromParentLeft - contentRect.width;
|
|
137
|
-
}
|
|
138
|
-
newOffset = clamp(desiredLeft, 0, maxTranslate);
|
|
139
|
-
}
|
|
140
|
-
const nextOffset = quantizeToDevicePixel(newOffset);
|
|
141
|
-
if (Math.abs(lastOffsetRef.current - nextOffset) > 0.5) {
|
|
142
|
-
if (resolvedEdge === "top" || resolvedEdge === "bottom") {
|
|
143
|
-
contentEl.style.transform = `translateY(${nextOffset}px)`;
|
|
144
|
-
} else {
|
|
145
|
-
contentEl.style.transform = `translateX(${nextOffset}px)`;
|
|
146
|
-
}
|
|
147
|
-
lastOffsetRef.current = nextOffset;
|
|
148
|
-
onTranslateChange(nextOffset, rootRef, contentRef);
|
|
149
|
-
}
|
|
150
|
-
if (debug) {
|
|
151
|
-
rootEl.style.outline = "1px dashed rgba(0,0,0,.2)";
|
|
152
|
-
contentEl.style.outline = "1px solid rgba(0,128,255,.35)";
|
|
153
|
-
}
|
|
154
|
-
queueMicrotask(() => {
|
|
155
|
-
mutatingRef.current = false;
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
react.useEffect(() => {
|
|
159
|
-
if (typeof window == "undefined") return;
|
|
160
|
-
const rootEl = rootRef.current;
|
|
161
|
-
if (!rootEl) return;
|
|
162
|
-
const parentEl = rootEl.parentElement;
|
|
163
|
-
console.log(parentEl);
|
|
164
|
-
if (!parentEl) return;
|
|
165
|
-
const targets = [parentEl];
|
|
166
|
-
const observerCallback = () => {
|
|
167
|
-
if (!mutatingRef.current) scheduleUpdate();
|
|
168
|
-
};
|
|
169
|
-
const io = new IntersectionObserver(observerCallback, {
|
|
170
|
-
root: ioRoot instanceof Element ? ioRoot : null,
|
|
171
|
-
threshold: 0,
|
|
172
|
-
rootMargin: "1px"
|
|
173
|
-
});
|
|
174
|
-
const ro = new ResizeObserver(observerCallback);
|
|
175
|
-
targets.forEach((t) => io.observe(t));
|
|
176
|
-
ro.observe(parentEl);
|
|
177
|
-
if (contentRef.current) {
|
|
178
|
-
ro.observe(contentRef.current);
|
|
179
|
-
}
|
|
180
|
-
const scrollTarget = ioRoot || window;
|
|
181
|
-
scrollTarget.addEventListener("scroll", scheduleUpdate, {
|
|
182
|
-
passive: true
|
|
183
|
-
});
|
|
184
|
-
window.addEventListener("resize", scheduleUpdate);
|
|
185
|
-
scheduleUpdate();
|
|
186
|
-
return () => {
|
|
187
|
-
io.disconnect();
|
|
188
|
-
ro.disconnect();
|
|
189
|
-
scrollTarget.removeEventListener("scroll", scheduleUpdate);
|
|
190
|
-
window.removeEventListener("resize", scheduleUpdate);
|
|
191
|
-
if (rafId.current != null) {
|
|
192
|
-
cancelAnimationFrame(rafId.current);
|
|
193
|
-
rafId.current = null;
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
}, [ioRoot, resolvedEdge, offset, debug]);
|
|
197
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
198
|
-
"div",
|
|
199
|
-
{
|
|
200
|
-
ref: rootRef,
|
|
201
|
-
className,
|
|
202
|
-
style: {
|
|
203
|
-
display: "block",
|
|
204
|
-
minWidth: 0,
|
|
205
|
-
minHeight: 0,
|
|
206
|
-
height: "100%",
|
|
207
|
-
// 부모 높이를 채우도록 설정
|
|
208
|
-
...style
|
|
209
|
-
},
|
|
210
|
-
...rest,
|
|
211
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
212
|
-
"div",
|
|
213
|
-
{
|
|
214
|
-
ref: contentRef,
|
|
215
|
-
style: contentDynamicStyle,
|
|
216
|
-
children
|
|
217
|
-
}
|
|
218
|
-
)
|
|
219
|
-
}
|
|
220
|
-
);
|
|
221
|
-
};
|
|
222
|
-
var FlexLayoutStickyBox_default = FlexLayoutStickyBox;
|
|
223
|
-
|
|
224
|
-
module.exports = FlexLayoutStickyBox_default;
|
|
225
|
-
//# sourceMappingURL=FlexLayoutStickyBox.cjs.map
|
|
226
|
-
//# sourceMappingURL=FlexLayoutStickyBox.cjs.map
|
|
1
|
+
"use strict";"use client";var L=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var W=(e,t)=>{for(var o in t)L(e,o,{get:t[o],enumerable:!0})},X=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of j(t))!U.call(e,u)&&u!==o&&L(e,u,{get:()=>t[u],enumerable:!(s=$(t,u))||s.enumerable});return e};var Y=e=>X(L({},"__esModule",{value:!0}),e);var Q={};W(Q,{default:()=>K});module.exports=Y(Q);var T=require("react/jsx-runtime"),n=require("react");function C(e,t,o){return Math.max(t,Math.min(o,e))}function V(){if(typeof document>"u")return null;let e=document.body;for(;e&&e!==document.documentElement&&e!==document.body;){const t=getComputedStyle(e),o=t.overflowY,s=t.overflowX;if(o==="auto"||o==="scroll"||s==="auto"||s==="scroll")return e;e=e.parentElement}return null}function F(e){if(typeof window>"u")return!0;if(!e)return document.documentElement.scrollHeight>window.innerHeight+1;const t=e;return t.scrollHeight>t.clientHeight+1}const B=typeof window<"u"&&window.devicePixelRatio||1;function G(e){return Math.round(e*B)/B}const J=({edge:e="auto",offset:t=16,scrollRoot:o=null,debug:s=!1,children:u,style:D,className:P,transitionDurationMs:S=200,onTranslateChange:O=()=>{},...k})=>{const v=(0,n.useRef)(t),R=(0,n.useRef)(null),w=(0,n.useRef)(null),g=(0,n.useRef)(!1),H=(0,n.useRef)(0),[f,x]=(0,n.useState)("top"),b=(0,n.useRef)(null),[z,A]=(0,n.useState)({});(0,n.useEffect)(()=>{A({willChange:"transform",transition:`transform ${S}ms linear`})},[S]),(0,n.useEffect)(()=>{v.current=t,d()},[t]);const[c,q]=(0,n.useState)(null);(0,n.useEffect)(()=>{const r=o??V();x(e==="auto"?F(r)?"top":"left":e),q(r)},[e,o]),(0,n.useEffect)(()=>{if(e!=="auto"){x(e);return}const r=F(c);x(r?"top":"left")},[e,c]),(0,n.useEffect)(()=>{},[]);const d=()=>{b.current==null&&(b.current=requestAnimationFrame(()=>{b.current=null,I()}))},I=()=>{if(g.current)return;g.current=!0;const r=R.current,i=w.current;if(!r||!i){g.current=!1;return}const y=r.parentElement;if(!y){g.current=!1;return}const m=c&&"getBoundingClientRect"in c?c.getBoundingClientRect():new DOMRect(0,0,window.innerWidth,window.innerHeight),l=y.getBoundingClientRect(),a=i.getBoundingClientRect();let E=0;if(f==="top"||f==="bottom"){const M=Math.max(0,l.height-a.height);let h=0;f==="top"?h=m.top+v.current-l.top:h=Math.min(l.bottom,m.bottom-v.current)-l.top-a.height,E=C(h,0,M)}else{const M=Math.max(0,l.width-a.width);let h=0;f==="left"?h=m.left+v.current-l.left:h=Math.min(l.right,m.right-v.current)-l.left-a.width,E=C(h,0,M)}const p=G(E);Math.abs(H.current-p)>.5&&(f==="top"||f==="bottom"?i.style.transform=`translateY(${p}px)`:i.style.transform=`translateX(${p}px)`,H.current=p,O(p,R,w)),s&&(r.style.outline="1px dashed rgba(0,0,0,.2)",i.style.outline="1px solid rgba(0,128,255,.35)"),queueMicrotask(()=>{g.current=!1})};return(0,n.useEffect)(()=>{if(typeof window>"u")return;const r=R.current;if(!r)return;const i=r.parentElement;if(console.log(i),!i)return;const y=[i],m=()=>{g.current||d()},l=new IntersectionObserver(m,{root:c instanceof Element?c:null,threshold:0,rootMargin:"1px"}),a=new ResizeObserver(m);y.forEach(p=>l.observe(p)),a.observe(i),w.current&&a.observe(w.current);const E=c||window;return E.addEventListener("scroll",d,{passive:!0}),window.addEventListener("resize",d),d(),()=>{l.disconnect(),a.disconnect(),E.removeEventListener("scroll",d),window.removeEventListener("resize",d),b.current!=null&&(cancelAnimationFrame(b.current),b.current=null)}},[c,f,t,s]),(0,T.jsx)("div",{ref:R,className:P,style:{display:"block",minWidth:0,minHeight:0,height:"100%",...D},...k,children:(0,T.jsx)("div",{ref:w,style:z,children:u})})};var K=J;
|
|
@@ -11,6 +11,7 @@ interface FlexLayoutStickyBoxProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
debug?: boolean;
|
|
12
12
|
/** 자식 */
|
|
13
13
|
children: ReactNode;
|
|
14
|
+
transitionDurationMs?: number;
|
|
14
15
|
onTranslateChange?: (value: number, rootRef: RefObject<HTMLDivElement | null>, contentRef: RefObject<HTMLDivElement | null>) => void;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
@@ -1,224 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useRef, useState, useEffect } from 'react';
|
|
3
|
-
|
|
4
|
-
function clamp(n, min, max) {
|
|
5
|
-
return Math.max(min, Math.min(max, n));
|
|
6
|
-
}
|
|
7
|
-
function pickDefaultScrollRoot() {
|
|
8
|
-
if (typeof document === "undefined") return null;
|
|
9
|
-
let el = document.body;
|
|
10
|
-
while (el && el !== document.documentElement && el !== document.body) {
|
|
11
|
-
const style = getComputedStyle(el);
|
|
12
|
-
const oy = style.overflowY;
|
|
13
|
-
const ox = style.overflowX;
|
|
14
|
-
const scrollable = oy === "auto" || oy === "scroll" || ox === "auto" || ox === "scroll";
|
|
15
|
-
if (scrollable) return el;
|
|
16
|
-
el = el.parentElement;
|
|
17
|
-
}
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
function isVerticalScroll(root) {
|
|
21
|
-
if (typeof window == "undefined") return true;
|
|
22
|
-
if (!root) {
|
|
23
|
-
return document.documentElement.scrollHeight > window.innerHeight + 1;
|
|
24
|
-
}
|
|
25
|
-
const el = root;
|
|
26
|
-
return el.scrollHeight > el.clientHeight + 1;
|
|
27
|
-
}
|
|
28
|
-
const dpr = typeof window != "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
29
|
-
function quantizeToDevicePixel(n) {
|
|
30
|
-
return Math.round(n * dpr) / dpr;
|
|
31
|
-
}
|
|
32
|
-
const FlexLayoutStickyBox = ({
|
|
33
|
-
edge = "auto",
|
|
34
|
-
offset = 16,
|
|
35
|
-
scrollRoot = null,
|
|
36
|
-
debug = false,
|
|
37
|
-
children,
|
|
38
|
-
style,
|
|
39
|
-
className,
|
|
40
|
-
onTranslateChange = () => {
|
|
41
|
-
},
|
|
42
|
-
...rest
|
|
43
|
-
}) => {
|
|
44
|
-
const offsetRef = useRef(offset);
|
|
45
|
-
const rootRef = useRef(null);
|
|
46
|
-
const contentRef = useRef(null);
|
|
47
|
-
const mutatingRef = useRef(false);
|
|
48
|
-
const lastOffsetRef = useRef(0);
|
|
49
|
-
const [resolvedEdge, setResolvedEdge] = useState("top");
|
|
50
|
-
const rafId = useRef(null);
|
|
51
|
-
const [contentDynamicStyle, setContentDynamicStyle] = useState({});
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
setContentDynamicStyle({
|
|
54
|
-
willChange: "transform",
|
|
55
|
-
transition: "transform 50ms linear"
|
|
56
|
-
});
|
|
57
|
-
}, []);
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
offsetRef.current = offset;
|
|
60
|
-
scheduleUpdate();
|
|
61
|
-
}, [offset]);
|
|
62
|
-
const [ioRoot, setIoRoot] = useState(null);
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
const root = scrollRoot ?? pickDefaultScrollRoot();
|
|
65
|
-
setResolvedEdge(
|
|
66
|
-
edge === "auto" ? isVerticalScroll(root) ? "top" : "left" : edge
|
|
67
|
-
);
|
|
68
|
-
setIoRoot(root);
|
|
69
|
-
}, [edge, scrollRoot]);
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
if (edge !== "auto") {
|
|
72
|
-
setResolvedEdge(edge);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const vertical = isVerticalScroll(ioRoot);
|
|
76
|
-
setResolvedEdge(vertical ? "top" : "left");
|
|
77
|
-
}, [edge, ioRoot]);
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
}, []);
|
|
80
|
-
const scheduleUpdate = () => {
|
|
81
|
-
if (rafId.current != null) return;
|
|
82
|
-
rafId.current = requestAnimationFrame(() => {
|
|
83
|
-
rafId.current = null;
|
|
84
|
-
doUpdate();
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
const doUpdate = () => {
|
|
88
|
-
if (mutatingRef.current) return;
|
|
89
|
-
mutatingRef.current = true;
|
|
90
|
-
const rootEl = rootRef.current;
|
|
91
|
-
const contentEl = contentRef.current;
|
|
92
|
-
if (!rootEl || !contentEl) {
|
|
93
|
-
mutatingRef.current = false;
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
const parentEl = rootEl.parentElement;
|
|
97
|
-
if (!parentEl) {
|
|
98
|
-
mutatingRef.current = false;
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const rootBounds = ioRoot && "getBoundingClientRect" in ioRoot ? ioRoot.getBoundingClientRect() : new DOMRect(0, 0, window.innerWidth, window.innerHeight);
|
|
102
|
-
const parentRect = parentEl.getBoundingClientRect();
|
|
103
|
-
const contentRect = contentEl.getBoundingClientRect();
|
|
104
|
-
let newOffset = 0;
|
|
105
|
-
if (resolvedEdge === "top" || resolvedEdge === "bottom") {
|
|
106
|
-
const maxTranslate = Math.max(
|
|
107
|
-
0,
|
|
108
|
-
parentRect.height - contentRect.height
|
|
109
|
-
);
|
|
110
|
-
let desiredTop = 0;
|
|
111
|
-
if (resolvedEdge === "top") {
|
|
112
|
-
desiredTop = rootBounds.top + offsetRef.current - parentRect.top;
|
|
113
|
-
} else {
|
|
114
|
-
const targetBottomFromParentTop = Math.min(
|
|
115
|
-
parentRect.bottom,
|
|
116
|
-
rootBounds.bottom - offsetRef.current
|
|
117
|
-
) - parentRect.top;
|
|
118
|
-
desiredTop = targetBottomFromParentTop - contentRect.height;
|
|
119
|
-
}
|
|
120
|
-
newOffset = clamp(desiredTop, 0, maxTranslate);
|
|
121
|
-
} else {
|
|
122
|
-
const maxTranslate = Math.max(
|
|
123
|
-
0,
|
|
124
|
-
parentRect.width - contentRect.width
|
|
125
|
-
);
|
|
126
|
-
let desiredLeft = 0;
|
|
127
|
-
if (resolvedEdge === "left") {
|
|
128
|
-
desiredLeft = rootBounds.left + offsetRef.current - parentRect.left;
|
|
129
|
-
} else {
|
|
130
|
-
const targetRightFromParentLeft = Math.min(
|
|
131
|
-
parentRect.right,
|
|
132
|
-
rootBounds.right - offsetRef.current
|
|
133
|
-
) - parentRect.left;
|
|
134
|
-
desiredLeft = targetRightFromParentLeft - contentRect.width;
|
|
135
|
-
}
|
|
136
|
-
newOffset = clamp(desiredLeft, 0, maxTranslate);
|
|
137
|
-
}
|
|
138
|
-
const nextOffset = quantizeToDevicePixel(newOffset);
|
|
139
|
-
if (Math.abs(lastOffsetRef.current - nextOffset) > 0.5) {
|
|
140
|
-
if (resolvedEdge === "top" || resolvedEdge === "bottom") {
|
|
141
|
-
contentEl.style.transform = `translateY(${nextOffset}px)`;
|
|
142
|
-
} else {
|
|
143
|
-
contentEl.style.transform = `translateX(${nextOffset}px)`;
|
|
144
|
-
}
|
|
145
|
-
lastOffsetRef.current = nextOffset;
|
|
146
|
-
onTranslateChange(nextOffset, rootRef, contentRef);
|
|
147
|
-
}
|
|
148
|
-
if (debug) {
|
|
149
|
-
rootEl.style.outline = "1px dashed rgba(0,0,0,.2)";
|
|
150
|
-
contentEl.style.outline = "1px solid rgba(0,128,255,.35)";
|
|
151
|
-
}
|
|
152
|
-
queueMicrotask(() => {
|
|
153
|
-
mutatingRef.current = false;
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
useEffect(() => {
|
|
157
|
-
if (typeof window == "undefined") return;
|
|
158
|
-
const rootEl = rootRef.current;
|
|
159
|
-
if (!rootEl) return;
|
|
160
|
-
const parentEl = rootEl.parentElement;
|
|
161
|
-
console.log(parentEl);
|
|
162
|
-
if (!parentEl) return;
|
|
163
|
-
const targets = [parentEl];
|
|
164
|
-
const observerCallback = () => {
|
|
165
|
-
if (!mutatingRef.current) scheduleUpdate();
|
|
166
|
-
};
|
|
167
|
-
const io = new IntersectionObserver(observerCallback, {
|
|
168
|
-
root: ioRoot instanceof Element ? ioRoot : null,
|
|
169
|
-
threshold: 0,
|
|
170
|
-
rootMargin: "1px"
|
|
171
|
-
});
|
|
172
|
-
const ro = new ResizeObserver(observerCallback);
|
|
173
|
-
targets.forEach((t) => io.observe(t));
|
|
174
|
-
ro.observe(parentEl);
|
|
175
|
-
if (contentRef.current) {
|
|
176
|
-
ro.observe(contentRef.current);
|
|
177
|
-
}
|
|
178
|
-
const scrollTarget = ioRoot || window;
|
|
179
|
-
scrollTarget.addEventListener("scroll", scheduleUpdate, {
|
|
180
|
-
passive: true
|
|
181
|
-
});
|
|
182
|
-
window.addEventListener("resize", scheduleUpdate);
|
|
183
|
-
scheduleUpdate();
|
|
184
|
-
return () => {
|
|
185
|
-
io.disconnect();
|
|
186
|
-
ro.disconnect();
|
|
187
|
-
scrollTarget.removeEventListener("scroll", scheduleUpdate);
|
|
188
|
-
window.removeEventListener("resize", scheduleUpdate);
|
|
189
|
-
if (rafId.current != null) {
|
|
190
|
-
cancelAnimationFrame(rafId.current);
|
|
191
|
-
rafId.current = null;
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
}, [ioRoot, resolvedEdge, offset, debug]);
|
|
195
|
-
return /* @__PURE__ */ jsx(
|
|
196
|
-
"div",
|
|
197
|
-
{
|
|
198
|
-
ref: rootRef,
|
|
199
|
-
className,
|
|
200
|
-
style: {
|
|
201
|
-
display: "block",
|
|
202
|
-
minWidth: 0,
|
|
203
|
-
minHeight: 0,
|
|
204
|
-
height: "100%",
|
|
205
|
-
// 부모 높이를 채우도록 설정
|
|
206
|
-
...style
|
|
207
|
-
},
|
|
208
|
-
...rest,
|
|
209
|
-
children: /* @__PURE__ */ jsx(
|
|
210
|
-
"div",
|
|
211
|
-
{
|
|
212
|
-
ref: contentRef,
|
|
213
|
-
style: contentDynamicStyle,
|
|
214
|
-
children
|
|
215
|
-
}
|
|
216
|
-
)
|
|
217
|
-
}
|
|
218
|
-
);
|
|
219
|
-
};
|
|
220
|
-
var FlexLayoutStickyBox_default = FlexLayoutStickyBox;
|
|
221
|
-
|
|
222
|
-
export { FlexLayoutStickyBox_default as default };
|
|
223
|
-
//# sourceMappingURL=FlexLayoutStickyBox.js.map
|
|
224
|
-
//# sourceMappingURL=FlexLayoutStickyBox.js.map
|
|
1
|
+
"use client";import{jsx as D}from"react/jsx-runtime";import{useEffect as g,useRef as b,useState as L}from"react";function C(e,t,c){return Math.max(t,Math.min(c,e))}function j(){if(typeof document>"u")return null;let e=document.body;for(;e&&e!==document.documentElement&&e!==document.body;){const t=getComputedStyle(e),c=t.overflowY,E=t.overflowX;if(c==="auto"||c==="scroll"||E==="auto"||E==="scroll")return e;e=e.parentElement}return null}function F(e){if(typeof window>"u")return!0;if(!e)return document.documentElement.scrollHeight>window.innerHeight+1;const t=e;return t.scrollHeight>t.clientHeight+1}const B=typeof window<"u"&&window.devicePixelRatio||1;function U(e){return Math.round(e*B)/B}const W=({edge:e="auto",offset:t=16,scrollRoot:c=null,debug:E=!1,children:T,style:P,className:O,transitionDurationMs:S=200,onTranslateChange:k=()=>{},...z})=>{const v=b(t),R=b(null),w=b(null),m=b(!1),H=b(0),[s,x]=L("top"),p=b(null),[A,q]=L({});g(()=>{q({willChange:"transform",transition:`transform ${S}ms linear`})},[S]),g(()=>{v.current=t,u()},[t]);const[l,I]=L(null);g(()=>{const n=c??j();x(e==="auto"?F(n)?"top":"left":e),I(n)},[e,c]),g(()=>{if(e!=="auto"){x(e);return}const n=F(l);x(n?"top":"left")},[e,l]),g(()=>{},[]);const u=()=>{p.current==null&&(p.current=requestAnimationFrame(()=>{p.current=null,N()}))},N=()=>{if(m.current)return;m.current=!0;const n=R.current,r=w.current;if(!n||!r){m.current=!1;return}const y=n.parentElement;if(!y){m.current=!1;return}const a=l&&"getBoundingClientRect"in l?l.getBoundingClientRect():new DOMRect(0,0,window.innerWidth,window.innerHeight),o=y.getBoundingClientRect(),i=r.getBoundingClientRect();let h=0;if(s==="top"||s==="bottom"){const M=Math.max(0,o.height-i.height);let d=0;s==="top"?d=a.top+v.current-o.top:d=Math.min(o.bottom,a.bottom-v.current)-o.top-i.height,h=C(d,0,M)}else{const M=Math.max(0,o.width-i.width);let d=0;s==="left"?d=a.left+v.current-o.left:d=Math.min(o.right,a.right-v.current)-o.left-i.width,h=C(d,0,M)}const f=U(h);Math.abs(H.current-f)>.5&&(s==="top"||s==="bottom"?r.style.transform=`translateY(${f}px)`:r.style.transform=`translateX(${f}px)`,H.current=f,k(f,R,w)),E&&(n.style.outline="1px dashed rgba(0,0,0,.2)",r.style.outline="1px solid rgba(0,128,255,.35)"),queueMicrotask(()=>{m.current=!1})};return g(()=>{if(typeof window>"u")return;const n=R.current;if(!n)return;const r=n.parentElement;if(console.log(r),!r)return;const y=[r],a=()=>{m.current||u()},o=new IntersectionObserver(a,{root:l instanceof Element?l:null,threshold:0,rootMargin:"1px"}),i=new ResizeObserver(a);y.forEach(f=>o.observe(f)),i.observe(r),w.current&&i.observe(w.current);const h=l||window;return h.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u),u(),()=>{o.disconnect(),i.disconnect(),h.removeEventListener("scroll",u),window.removeEventListener("resize",u),p.current!=null&&(cancelAnimationFrame(p.current),p.current=null)}},[l,s,t,E]),D("div",{ref:R,className:O,style:{display:"block",minWidth:0,minHeight:0,height:"100%",...P},...z,children:D("div",{ref:w,style:A,children:T})})};var Q=W;export{Q as default};
|
|
@@ -1,52 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var FlexLayout = require('./FlexLayout');
|
|
4
|
-
var FlexLayoutContainer = require('./FlexLayoutContainer');
|
|
5
|
-
var FlexLayoutResizePanel = require('./FlexLayoutResizePanel');
|
|
6
|
-
var FlexLayoutSplitScreen = require('./FlexLayoutSplitScreen');
|
|
7
|
-
var FlexLayoutSplitScreenDragBox = require('./FlexLayoutSplitScreenDragBox');
|
|
8
|
-
var FlexLayoutSplitScreenScrollBox = require('./FlexLayoutSplitScreenScrollBox');
|
|
9
|
-
var FlexLayoutStickyBox = require('./FlexLayoutStickyBox');
|
|
10
|
-
|
|
11
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
|
|
13
|
-
var FlexLayout__default = /*#__PURE__*/_interopDefault(FlexLayout);
|
|
14
|
-
var FlexLayoutContainer__default = /*#__PURE__*/_interopDefault(FlexLayoutContainer);
|
|
15
|
-
var FlexLayoutResizePanel__default = /*#__PURE__*/_interopDefault(FlexLayoutResizePanel);
|
|
16
|
-
var FlexLayoutSplitScreen__default = /*#__PURE__*/_interopDefault(FlexLayoutSplitScreen);
|
|
17
|
-
var FlexLayoutSplitScreenDragBox__default = /*#__PURE__*/_interopDefault(FlexLayoutSplitScreenDragBox);
|
|
18
|
-
var FlexLayoutSplitScreenScrollBox__default = /*#__PURE__*/_interopDefault(FlexLayoutSplitScreenScrollBox);
|
|
19
|
-
var FlexLayoutStickyBox__default = /*#__PURE__*/_interopDefault(FlexLayoutStickyBox);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Object.defineProperty(exports, "FlexLayout", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function () { return FlexLayout__default.default; }
|
|
26
|
-
});
|
|
27
|
-
Object.defineProperty(exports, "FlexLayoutContainer", {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function () { return FlexLayoutContainer__default.default; }
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(exports, "FlexLayoutResizePanel", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () { return FlexLayoutResizePanel__default.default; }
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(exports, "FlexLayoutSplitScreen", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
get: function () { return FlexLayoutSplitScreen__default.default; }
|
|
38
|
-
});
|
|
39
|
-
Object.defineProperty(exports, "FlexLayoutSplitScreenDragBox", {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
get: function () { return FlexLayoutSplitScreenDragBox__default.default; }
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(exports, "FlexLayoutSplitScreenScrollBox", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () { return FlexLayoutSplitScreenScrollBox__default.default; }
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(exports, "FlexLayoutStickyBox", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
get: function () { return FlexLayoutStickyBox__default.default; }
|
|
50
|
-
});
|
|
51
|
-
//# sourceMappingURL=index.cjs.map
|
|
52
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
"use strict";var F=Object.create;var r=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var n=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var B=(e,o)=>{for(var t in o)r(e,t,{get:o[t],enumerable:!0})},f=(e,o,t,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of i(o))!c.call(e,l)&&l!==t&&r(e,l,{get:()=>o[l],enumerable:!(x=L(o,l))||x.enumerable});return e};var a=(e,o,t)=>(t=e!=null?F(n(e)):{},f(o||!e||!e.__esModule?r(t,"default",{value:e,enumerable:!0}):t,e)),g=e=>f(r({},"__esModule",{value:!0}),e);var k={};B(k,{FlexLayout:()=>u.default,FlexLayoutContainer:()=>p.default,FlexLayoutResizePanel:()=>s.default,FlexLayoutSplitScreen:()=>y.default,FlexLayoutSplitScreenDragBox:()=>S.default,FlexLayoutSplitScreenScrollBox:()=>d.default,FlexLayoutStickyBox:()=>m.default});module.exports=g(k);var u=a(require("./FlexLayout"),1),p=a(require("./FlexLayoutContainer"),1),s=a(require("./FlexLayoutResizePanel"),1),y=a(require("./FlexLayoutSplitScreen"),1),S=a(require("./FlexLayoutSplitScreenDragBox"),1),d=a(require("./FlexLayoutSplitScreenScrollBox"),1),m=a(require("./FlexLayoutStickyBox"),1);0&&(module.exports={FlexLayout,FlexLayoutContainer,FlexLayoutResizePanel,FlexLayoutSplitScreen,FlexLayoutSplitScreenDragBox,FlexLayoutSplitScreenScrollBox,FlexLayoutStickyBox});
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { default as FlexLayoutContainer } from './FlexLayoutContainer';
|
|
3
|
-
export { default as FlexLayoutResizePanel } from './FlexLayoutResizePanel';
|
|
4
|
-
export { default as FlexLayoutSplitScreen } from './FlexLayoutSplitScreen';
|
|
5
|
-
export { default as FlexLayoutSplitScreenDragBox } from './FlexLayoutSplitScreenDragBox';
|
|
6
|
-
export { default as FlexLayoutSplitScreenScrollBox } from './FlexLayoutSplitScreenScrollBox';
|
|
7
|
-
export { default as FlexLayoutStickyBox } from './FlexLayoutStickyBox';
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{default as t}from"./FlexLayout";import{default as l}from"./FlexLayoutContainer";import{default as x}from"./FlexLayoutResizePanel";import{default as u}from"./FlexLayoutSplitScreen";import{default as s}from"./FlexLayoutSplitScreenDragBox";import{default as S}from"./FlexLayoutSplitScreenScrollBox";import{default as m}from"./FlexLayoutStickyBox";export{t as FlexLayout,l as FlexLayoutContainer,x as FlexLayoutResizePanel,u as FlexLayoutSplitScreen,s as FlexLayoutSplitScreenDragBox,S as FlexLayoutSplitScreenScrollBox,m as FlexLayoutStickyBox};
|
|
@@ -1,21 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var useDrag = require('./useDrag');
|
|
4
|
-
var useListPaging = require('./useListPaging');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.keys(useDrag).forEach(function (k) {
|
|
9
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () { return useDrag[k]; }
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
Object.keys(useListPaging).forEach(function (k) {
|
|
15
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return useListPaging[k]; }
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
//# sourceMappingURL=index.cjs.map
|
|
21
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(r,o,p,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of c(o))!d.call(r,m)&&m!==p&&a(r,m,{get:()=>o[m],enumerable:!(x=b(o,m))||x.enumerable});return r},f=(r,o,p)=>(t(r,o,"default"),p&&t(p,o,"default"));var g=r=>t(a({},"__esModule",{value:!0}),r);var e={};module.exports=g(e);f(e,require("./useDrag"),module.exports);f(e,require("./useListPaging"),module.exports);0&&(module.exports={...require("./useDrag"),...require("./useListPaging")});
|