@tamagui/use-element-layout 1.129.6-1751237024118
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/LICENSE +21 -0
- package/dist/cjs/index.cjs +228 -0
- package/dist/cjs/index.js +166 -0
- package/dist/cjs/index.js.map +6 -0
- package/dist/cjs/index.native.js +210 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/esm/index.js +151 -0
- package/dist/esm/index.js.map +6 -0
- package/dist/esm/index.mjs +198 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +214 -0
- package/dist/esm/index.native.js.map +1 -0
- package/package.json +48 -0
- package/src/index.ts +304 -0
- package/types/index.d.ts +32 -0
- package/types/index.d.ts.map +27 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { isClient, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
|
+
import { isEqualShallow } from "@tamagui/is-equal-shallow";
|
|
3
|
+
const LayoutHandlers = /* @__PURE__ */ new WeakMap(), Nodes = /* @__PURE__ */ new Set();
|
|
4
|
+
let strategy = "async";
|
|
5
|
+
function setOnLayoutStrategy(state) {
|
|
6
|
+
strategy = state;
|
|
7
|
+
}
|
|
8
|
+
const NodeRectCache = /* @__PURE__ */ new WeakMap(), ParentRectCache = /* @__PURE__ */ new WeakMap(), DebounceTimers = /* @__PURE__ */ new WeakMap(), LastChangeTime = /* @__PURE__ */ new WeakMap(), rAF = typeof window < "u" ? window.requestAnimationFrame : void 0, DEBOUNCE_DELAY = 32;
|
|
9
|
+
let avoidUpdates = !0;
|
|
10
|
+
const queuedUpdates = /* @__PURE__ */ new Map();
|
|
11
|
+
function enable() {
|
|
12
|
+
avoidUpdates && (avoidUpdates = !1, queuedUpdates && (queuedUpdates.forEach((cb) => cb()), queuedUpdates.clear()));
|
|
13
|
+
}
|
|
14
|
+
if (isClient)
|
|
15
|
+
if (rAF) {
|
|
16
|
+
let layoutOnAnimationFrame = function() {
|
|
17
|
+
const now = Date.now(), timeSinceLastFrame = now - lastFrameAt;
|
|
18
|
+
lastFrameAt = now, strategy !== "off" && (timeSinceLastFrame > 16.67 * numDroppedFramesUntilPause || Nodes.forEach(updateLayoutIfChanged)), rAF(layoutOnAnimationFrame);
|
|
19
|
+
}, lastFrameAt = Date.now();
|
|
20
|
+
const numDroppedFramesUntilPause = 2;
|
|
21
|
+
async function updateLayoutIfChanged(node) {
|
|
22
|
+
const nodeRect = node.getBoundingClientRect(), parentNode = node.parentElement, parentRect = parentNode?.getBoundingClientRect(), onLayout = LayoutHandlers.get(node);
|
|
23
|
+
if (typeof onLayout != "function") return;
|
|
24
|
+
const cachedRect = NodeRectCache.get(node), cachedParentRect = parentNode ? NodeRectCache.get(parentNode) : null;
|
|
25
|
+
if (!cachedRect || // has changed one rect
|
|
26
|
+
!isEqualShallow(cachedRect, nodeRect) && (!cachedParentRect || !isEqualShallow(cachedParentRect, parentRect)))
|
|
27
|
+
if (NodeRectCache.set(node, nodeRect), parentRect && parentNode && ParentRectCache.set(parentNode, parentRect), avoidUpdates) {
|
|
28
|
+
const event = getElementLayoutEvent(node);
|
|
29
|
+
queuedUpdates.set(node, () => onLayout(event));
|
|
30
|
+
} else if (strategy === "async") {
|
|
31
|
+
const now = Date.now();
|
|
32
|
+
LastChangeTime.set(node, now);
|
|
33
|
+
const existingTimer = DebounceTimers.get(node);
|
|
34
|
+
existingTimer && clearTimeout(existingTimer);
|
|
35
|
+
const timer = setTimeout(async () => {
|
|
36
|
+
const lastChange = LastChangeTime.get(node) || 0, timeSinceChange = Date.now() - lastChange;
|
|
37
|
+
if (timeSinceChange >= DEBOUNCE_DELAY) {
|
|
38
|
+
const event = await getElementLayoutEventAsync(node);
|
|
39
|
+
onLayout(event), DebounceTimers.delete(node);
|
|
40
|
+
} else {
|
|
41
|
+
const remainingDelay = DEBOUNCE_DELAY - timeSinceChange, newTimer = setTimeout(async () => {
|
|
42
|
+
const event = await getElementLayoutEventAsync(node);
|
|
43
|
+
onLayout(event), DebounceTimers.delete(node);
|
|
44
|
+
}, remainingDelay);
|
|
45
|
+
DebounceTimers.set(node, newTimer);
|
|
46
|
+
}
|
|
47
|
+
}, DEBOUNCE_DELAY);
|
|
48
|
+
DebounceTimers.set(node, timer);
|
|
49
|
+
} else {
|
|
50
|
+
const event = getElementLayoutEvent(node);
|
|
51
|
+
onLayout(event);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
rAF(layoutOnAnimationFrame);
|
|
55
|
+
} else
|
|
56
|
+
process.env.NODE_ENV === "development" && console.warn(
|
|
57
|
+
"No requestAnimationFrame - please polyfill for onLayout to work correctly"
|
|
58
|
+
);
|
|
59
|
+
const getElementLayoutEvent = (target) => {
|
|
60
|
+
let res = null;
|
|
61
|
+
if (measureLayout(target, null, (x, y, width, height, left, top) => {
|
|
62
|
+
res = {
|
|
63
|
+
nativeEvent: {
|
|
64
|
+
layout: { x, y, width, height, left, top },
|
|
65
|
+
target
|
|
66
|
+
},
|
|
67
|
+
timeStamp: Date.now()
|
|
68
|
+
};
|
|
69
|
+
}), !res)
|
|
70
|
+
throw new Error("\u203C\uFE0F");
|
|
71
|
+
return res;
|
|
72
|
+
}, measureLayout = (node, relativeTo, callback) => {
|
|
73
|
+
const relativeNode = relativeTo || node?.parentElement;
|
|
74
|
+
if (relativeNode instanceof HTMLElement) {
|
|
75
|
+
const nodeDim = node.getBoundingClientRect(), relativeNodeDim = relativeNode.getBoundingClientRect();
|
|
76
|
+
if (relativeNodeDim && nodeDim) {
|
|
77
|
+
const { x, y, width, height, left, top } = getRelativeDimensions(
|
|
78
|
+
nodeDim,
|
|
79
|
+
relativeNodeDim
|
|
80
|
+
);
|
|
81
|
+
callback(x, y, width, height, left, top);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, getElementLayoutEventAsync = async (target) => {
|
|
85
|
+
const layout = await measureLayoutAsync(target);
|
|
86
|
+
if (!layout)
|
|
87
|
+
throw new Error("\u203C\uFE0F");
|
|
88
|
+
return {
|
|
89
|
+
nativeEvent: {
|
|
90
|
+
layout,
|
|
91
|
+
target
|
|
92
|
+
},
|
|
93
|
+
timeStamp: Date.now()
|
|
94
|
+
};
|
|
95
|
+
}, measureLayoutAsync = async (node, relativeTo) => {
|
|
96
|
+
const relativeNode = relativeTo || node?.parentElement;
|
|
97
|
+
if (relativeNode instanceof HTMLElement) {
|
|
98
|
+
const [nodeDim, relativeNodeDim] = await Promise.all([
|
|
99
|
+
node.getBoundingClientRect(),
|
|
100
|
+
relativeNode.getBoundingClientRect()
|
|
101
|
+
]);
|
|
102
|
+
if (relativeNodeDim && nodeDim) {
|
|
103
|
+
const { x, y, width, height, left, top } = getRelativeDimensions(
|
|
104
|
+
nodeDim,
|
|
105
|
+
relativeNodeDim
|
|
106
|
+
);
|
|
107
|
+
return { x, y, width, height, left, top };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}, getRelativeDimensions = (a, b) => {
|
|
112
|
+
const { height, left, top, width } = a, x = left - b.left, y = top - b.top;
|
|
113
|
+
return { x, y, width, height, left, top };
|
|
114
|
+
};
|
|
115
|
+
function useElementLayout(ref, onLayout) {
|
|
116
|
+
const node = ensureWebElement(ref.current?.host);
|
|
117
|
+
node && onLayout && LayoutHandlers.set(node, onLayout), useIsomorphicLayoutEffect(() => {
|
|
118
|
+
if (!onLayout) return;
|
|
119
|
+
const node2 = ref.current?.host;
|
|
120
|
+
if (node2)
|
|
121
|
+
return LayoutHandlers.set(node2, onLayout), Nodes.add(node2), onLayout(getElementLayoutEvent(node2)), () => {
|
|
122
|
+
Nodes.delete(node2), LayoutHandlers.delete(node2), NodeRectCache.delete(node2);
|
|
123
|
+
const timer = DebounceTimers.get(node2);
|
|
124
|
+
timer && (clearTimeout(timer), DebounceTimers.delete(node2)), LastChangeTime.delete(node2);
|
|
125
|
+
};
|
|
126
|
+
}, [ref, !!onLayout]);
|
|
127
|
+
}
|
|
128
|
+
function ensureWebElement(x) {
|
|
129
|
+
if (!(typeof HTMLElement > "u"))
|
|
130
|
+
return x instanceof HTMLElement ? x : void 0;
|
|
131
|
+
}
|
|
132
|
+
const getBoundingClientRect = (node) => {
|
|
133
|
+
if (!(!node || node.nodeType !== 1))
|
|
134
|
+
return node.getBoundingClientRect?.();
|
|
135
|
+
}, getRect = (node) => {
|
|
136
|
+
const rect = getBoundingClientRect(node);
|
|
137
|
+
if (!rect) return;
|
|
138
|
+
const { x, y, top, left } = rect;
|
|
139
|
+
return { x, y, width: node.offsetWidth, height: node.offsetHeight, top, left };
|
|
140
|
+
};
|
|
141
|
+
export {
|
|
142
|
+
enable,
|
|
143
|
+
getElementLayoutEvent,
|
|
144
|
+
getElementLayoutEventAsync,
|
|
145
|
+
getRect,
|
|
146
|
+
measureLayout,
|
|
147
|
+
measureLayoutAsync,
|
|
148
|
+
setOnLayoutStrategy,
|
|
149
|
+
useElementLayout
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"mappings": "AAAA,SAAS,UAAU,iCAAiC;AACpD,SAAS,sBAAsB;AAG/B,MAAM,iBAAiB,oBAAI,QAA+B,GACpD,QAAQ,oBAAI,IAAiB;AAQnC,IAAI,WAAsC;AAEnC,SAAS,oBAAoB,OAAwC;AAC1E,aAAW;AACb;AAmBA,MAAM,gBAAgB,oBAAI,QAA8B,GAClD,kBAAkB,oBAAI,QAA8B,GACpD,iBAAiB,oBAAI,QAAqC,GAC1D,iBAAiB,oBAAI,QAA6B,GAElD,MAAM,OAAO,SAAW,MAAc,OAAO,wBAAwB,QACrE,iBAAiB;AAGvB,IAAI,eAAe;AACnB,MAAM,gBAAgB,oBAAI,IAA2B;AAE9C,SAAS,SAAe;AAC7B,EAAI,iBACF,eAAe,IACX,kBACF,cAAc,QAAQ,CAAC,OAAO,GAAG,CAAC,G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,QAAI,UACF,aAAa,KAAK,GAClB,eAAe,OAAOA,KAAI,IAE5B,eAAe,OAAOA,KAAI;AAAA,MAC5B;AAAA,EACF,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC;AACtB;AAEA,SAAS,iBAAoB,GAA+B;AAC1D,MAAI,SAAO,cAAgB;AAG3B,WAAO,aAAa,cAAc,IAAI;AACxC;AAEA,MAAM,wBAAwB,CAAC,SAAkD;AAC/E,MAAI,GAAC,QAAQ,KAAK,aAAa;AAC/B,WAAO,KAAK,wBAAwB;AACtC,GAEa,UAAU,CAAC,SAA+C;AACrE,QAAM,OAAO,sBAAsB,IAAI;AACvC,MAAI,CAAC,KAAM;AACX,QAAM,EAAE,GAAG,GAAG,KAAK,KAAK,IAAI;AAC5B,SAAO,EAAE,GAAG,GAAG,OAAO,KAAK,aAAa,QAAQ,KAAK,cAAc,KAAK,KAAK;AAC/E;",
|
|
5
|
+
"names": ["node"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { isClient, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
|
+
import { isEqualShallow } from "@tamagui/is-equal-shallow";
|
|
3
|
+
const LayoutHandlers = /* @__PURE__ */new WeakMap(),
|
|
4
|
+
Nodes = /* @__PURE__ */new Set();
|
|
5
|
+
let strategy = "async";
|
|
6
|
+
function setOnLayoutStrategy(state) {
|
|
7
|
+
strategy = state;
|
|
8
|
+
}
|
|
9
|
+
const NodeRectCache = /* @__PURE__ */new WeakMap(),
|
|
10
|
+
ParentRectCache = /* @__PURE__ */new WeakMap(),
|
|
11
|
+
DebounceTimers = /* @__PURE__ */new WeakMap(),
|
|
12
|
+
LastChangeTime = /* @__PURE__ */new WeakMap(),
|
|
13
|
+
rAF = typeof window < "u" ? window.requestAnimationFrame : void 0,
|
|
14
|
+
DEBOUNCE_DELAY = 32;
|
|
15
|
+
let avoidUpdates = !0;
|
|
16
|
+
const queuedUpdates = /* @__PURE__ */new Map();
|
|
17
|
+
function enable() {
|
|
18
|
+
avoidUpdates && (avoidUpdates = !1, queuedUpdates && (queuedUpdates.forEach(cb => cb()), queuedUpdates.clear()));
|
|
19
|
+
}
|
|
20
|
+
if (isClient) if (rAF) {
|
|
21
|
+
let layoutOnAnimationFrame = function () {
|
|
22
|
+
const now = Date.now(),
|
|
23
|
+
timeSinceLastFrame = now - lastFrameAt;
|
|
24
|
+
lastFrameAt = now, strategy !== "off" && (timeSinceLastFrame > 16.67 * numDroppedFramesUntilPause || Nodes.forEach(updateLayoutIfChanged)), rAF(layoutOnAnimationFrame);
|
|
25
|
+
},
|
|
26
|
+
lastFrameAt = Date.now();
|
|
27
|
+
const numDroppedFramesUntilPause = 2;
|
|
28
|
+
async function updateLayoutIfChanged(node) {
|
|
29
|
+
const nodeRect = node.getBoundingClientRect(),
|
|
30
|
+
parentNode = node.parentElement,
|
|
31
|
+
parentRect = parentNode?.getBoundingClientRect(),
|
|
32
|
+
onLayout = LayoutHandlers.get(node);
|
|
33
|
+
if (typeof onLayout != "function") return;
|
|
34
|
+
const cachedRect = NodeRectCache.get(node),
|
|
35
|
+
cachedParentRect = parentNode ? NodeRectCache.get(parentNode) : null;
|
|
36
|
+
if (!cachedRect ||
|
|
37
|
+
// has changed one rect
|
|
38
|
+
!isEqualShallow(cachedRect, nodeRect) && (!cachedParentRect || !isEqualShallow(cachedParentRect, parentRect))) if (NodeRectCache.set(node, nodeRect), parentRect && parentNode && ParentRectCache.set(parentNode, parentRect), avoidUpdates) {
|
|
39
|
+
const event = getElementLayoutEvent(node);
|
|
40
|
+
queuedUpdates.set(node, () => onLayout(event));
|
|
41
|
+
} else if (strategy === "async") {
|
|
42
|
+
const now = Date.now();
|
|
43
|
+
LastChangeTime.set(node, now);
|
|
44
|
+
const existingTimer = DebounceTimers.get(node);
|
|
45
|
+
existingTimer && clearTimeout(existingTimer);
|
|
46
|
+
const timer = setTimeout(async () => {
|
|
47
|
+
const lastChange = LastChangeTime.get(node) || 0,
|
|
48
|
+
timeSinceChange = Date.now() - lastChange;
|
|
49
|
+
if (timeSinceChange >= DEBOUNCE_DELAY) {
|
|
50
|
+
const event = await getElementLayoutEventAsync(node);
|
|
51
|
+
onLayout(event), DebounceTimers.delete(node);
|
|
52
|
+
} else {
|
|
53
|
+
const remainingDelay = DEBOUNCE_DELAY - timeSinceChange,
|
|
54
|
+
newTimer = setTimeout(async () => {
|
|
55
|
+
const event = await getElementLayoutEventAsync(node);
|
|
56
|
+
onLayout(event), DebounceTimers.delete(node);
|
|
57
|
+
}, remainingDelay);
|
|
58
|
+
DebounceTimers.set(node, newTimer);
|
|
59
|
+
}
|
|
60
|
+
}, DEBOUNCE_DELAY);
|
|
61
|
+
DebounceTimers.set(node, timer);
|
|
62
|
+
} else {
|
|
63
|
+
const event = getElementLayoutEvent(node);
|
|
64
|
+
onLayout(event);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
rAF(layoutOnAnimationFrame);
|
|
68
|
+
} else process.env.NODE_ENV === "development" && console.warn("No requestAnimationFrame - please polyfill for onLayout to work correctly");
|
|
69
|
+
const getElementLayoutEvent = target => {
|
|
70
|
+
let res = null;
|
|
71
|
+
if (measureLayout(target, null, (x, y, width, height, left, top) => {
|
|
72
|
+
res = {
|
|
73
|
+
nativeEvent: {
|
|
74
|
+
layout: {
|
|
75
|
+
x,
|
|
76
|
+
y,
|
|
77
|
+
width,
|
|
78
|
+
height,
|
|
79
|
+
left,
|
|
80
|
+
top
|
|
81
|
+
},
|
|
82
|
+
target
|
|
83
|
+
},
|
|
84
|
+
timeStamp: Date.now()
|
|
85
|
+
};
|
|
86
|
+
}), !res) throw new Error("\u203C\uFE0F");
|
|
87
|
+
return res;
|
|
88
|
+
},
|
|
89
|
+
measureLayout = (node, relativeTo, callback) => {
|
|
90
|
+
const relativeNode = relativeTo || node?.parentElement;
|
|
91
|
+
if (relativeNode instanceof HTMLElement) {
|
|
92
|
+
const nodeDim = node.getBoundingClientRect(),
|
|
93
|
+
relativeNodeDim = relativeNode.getBoundingClientRect();
|
|
94
|
+
if (relativeNodeDim && nodeDim) {
|
|
95
|
+
const {
|
|
96
|
+
x,
|
|
97
|
+
y,
|
|
98
|
+
width,
|
|
99
|
+
height,
|
|
100
|
+
left,
|
|
101
|
+
top
|
|
102
|
+
} = getRelativeDimensions(nodeDim, relativeNodeDim);
|
|
103
|
+
callback(x, y, width, height, left, top);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
getElementLayoutEventAsync = async target => {
|
|
108
|
+
const layout = await measureLayoutAsync(target);
|
|
109
|
+
if (!layout) throw new Error("\u203C\uFE0F");
|
|
110
|
+
return {
|
|
111
|
+
nativeEvent: {
|
|
112
|
+
layout,
|
|
113
|
+
target
|
|
114
|
+
},
|
|
115
|
+
timeStamp: Date.now()
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
measureLayoutAsync = async (node, relativeTo) => {
|
|
119
|
+
const relativeNode = relativeTo || node?.parentElement;
|
|
120
|
+
if (relativeNode instanceof HTMLElement) {
|
|
121
|
+
const [nodeDim, relativeNodeDim] = await Promise.all([node.getBoundingClientRect(), relativeNode.getBoundingClientRect()]);
|
|
122
|
+
if (relativeNodeDim && nodeDim) {
|
|
123
|
+
const {
|
|
124
|
+
x,
|
|
125
|
+
y,
|
|
126
|
+
width,
|
|
127
|
+
height,
|
|
128
|
+
left,
|
|
129
|
+
top
|
|
130
|
+
} = getRelativeDimensions(nodeDim, relativeNodeDim);
|
|
131
|
+
return {
|
|
132
|
+
x,
|
|
133
|
+
y,
|
|
134
|
+
width,
|
|
135
|
+
height,
|
|
136
|
+
left,
|
|
137
|
+
top
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
},
|
|
143
|
+
getRelativeDimensions = (a, b) => {
|
|
144
|
+
const {
|
|
145
|
+
height,
|
|
146
|
+
left,
|
|
147
|
+
top,
|
|
148
|
+
width
|
|
149
|
+
} = a,
|
|
150
|
+
x = left - b.left,
|
|
151
|
+
y = top - b.top;
|
|
152
|
+
return {
|
|
153
|
+
x,
|
|
154
|
+
y,
|
|
155
|
+
width,
|
|
156
|
+
height,
|
|
157
|
+
left,
|
|
158
|
+
top
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
function useElementLayout(ref, onLayout) {
|
|
162
|
+
const node = ensureWebElement(ref.current?.host);
|
|
163
|
+
node && onLayout && LayoutHandlers.set(node, onLayout), useIsomorphicLayoutEffect(() => {
|
|
164
|
+
if (!onLayout) return;
|
|
165
|
+
const node2 = ref.current?.host;
|
|
166
|
+
if (node2) return LayoutHandlers.set(node2, onLayout), Nodes.add(node2), onLayout(getElementLayoutEvent(node2)), () => {
|
|
167
|
+
Nodes.delete(node2), LayoutHandlers.delete(node2), NodeRectCache.delete(node2);
|
|
168
|
+
const timer = DebounceTimers.get(node2);
|
|
169
|
+
timer && (clearTimeout(timer), DebounceTimers.delete(node2)), LastChangeTime.delete(node2);
|
|
170
|
+
};
|
|
171
|
+
}, [ref, !!onLayout]);
|
|
172
|
+
}
|
|
173
|
+
function ensureWebElement(x) {
|
|
174
|
+
if (!(typeof HTMLElement > "u")) return x instanceof HTMLElement ? x : void 0;
|
|
175
|
+
}
|
|
176
|
+
const getBoundingClientRect = node => {
|
|
177
|
+
if (!(!node || node.nodeType !== 1)) return node.getBoundingClientRect?.();
|
|
178
|
+
},
|
|
179
|
+
getRect = node => {
|
|
180
|
+
const rect = getBoundingClientRect(node);
|
|
181
|
+
if (!rect) return;
|
|
182
|
+
const {
|
|
183
|
+
x,
|
|
184
|
+
y,
|
|
185
|
+
top,
|
|
186
|
+
left
|
|
187
|
+
} = rect;
|
|
188
|
+
return {
|
|
189
|
+
x,
|
|
190
|
+
y,
|
|
191
|
+
width: node.offsetWidth,
|
|
192
|
+
height: node.offsetHeight,
|
|
193
|
+
top,
|
|
194
|
+
left
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
export { enable, getElementLayoutEvent, getElementLayoutEventAsync, getRect, measureLayout, measureLayoutAsync, setOnLayoutStrategy, useElementLayout };
|
|
198
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isClient","useIsomorphicLayoutEffect","isEqualShallow","LayoutHandlers","WeakMap","Nodes","Set","strategy","setOnLayoutStrategy","state","NodeRectCache","ParentRectCache","DebounceTimers","LastChangeTime","rAF","window","requestAnimationFrame","DEBOUNCE_DELAY","avoidUpdates","queuedUpdates","Map","enable","forEach","cb","clear","layoutOnAnimationFrame","now","Date","timeSinceLastFrame","lastFrameAt","numDroppedFramesUntilPause","updateLayoutIfChanged","node","nodeRect","getBoundingClientRect","parentNode","parentElement","parentRect","onLayout","get","cachedRect","cachedParentRect","set","event","getElementLayoutEvent","existingTimer","clearTimeout","timer","setTimeout","lastChange","timeSinceChange","getElementLayoutEventAsync","delete","remainingDelay","newTimer","process","env","NODE_ENV","console","warn","target","res","measureLayout","x","y","width","height","left","top","nativeEvent","layout","timeStamp","Error","relativeTo","callback","relativeNode","HTMLElement","nodeDim","relativeNodeDim","getRelativeDimensions","measureLayoutAsync","Promise","all","a","b","useElementLayout","ref","ensureWebElement","current","host","node2","add","nodeType","getRect","rect","offsetWidth","offsetHeight"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAA,EAAUC,yBAAA,QAAiC;AACpD,SAASC,cAAA,QAAsB;AAG/B,MAAMC,cAAA,GAAiB,mBAAIC,OAAA,CAA+B;EACpDC,KAAA,GAAQ,mBAAIC,GAAA,CAAiB;AAQnC,IAAIC,QAAA,GAAsC;AAEnC,SAASC,oBAAoBC,KAAA,EAAwC;EAC1EF,QAAA,GAAWE,KAAA;AACb;AAmBA,MAAMC,aAAA,GAAgB,mBAAIN,OAAA,CAA8B;EAClDO,eAAA,GAAkB,mBAAIP,OAAA,CAA8B;EACpDQ,cAAA,GAAiB,mBAAIR,OAAA,CAAqC;EAC1DS,cA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MAAM7B,qBAAA,GAAyBF,IAAA,IAAkD;IAC/E,IAAI,GAACA,IAAA,IAAQA,IAAA,CAAK4D,QAAA,KAAa,IAC/B,OAAO5D,IAAA,CAAKE,qBAAA,GAAwB;EACtC;EAEa2D,OAAA,GAAW7D,IAAA,IAA+C;IACrE,MAAM8D,IAAA,GAAO5D,qBAAA,CAAsBF,IAAI;IACvC,IAAI,CAAC8D,IAAA,EAAM;IACX,MAAM;MAAE/B,CAAA;MAAGC,CAAA;MAAGI,GAAA;MAAKD;IAAK,IAAI2B,IAAA;IAC5B,OAAO;MAAE/B,CAAA;MAAGC,CAAA;MAAGC,KAAA,EAAOjC,IAAA,CAAK+D,WAAA;MAAa7B,MAAA,EAAQlC,IAAA,CAAKgE,YAAA;MAAc5B,GAAA;MAAKD;IAAK;EAC/E","ignoreList":[]}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { isClient, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
|
+
import { isEqualShallow } from "@tamagui/is-equal-shallow";
|
|
3
|
+
var LayoutHandlers = /* @__PURE__ */new WeakMap(),
|
|
4
|
+
Nodes = /* @__PURE__ */new Set(),
|
|
5
|
+
strategy = "async";
|
|
6
|
+
function setOnLayoutStrategy(state) {
|
|
7
|
+
strategy = state;
|
|
8
|
+
}
|
|
9
|
+
var NodeRectCache = /* @__PURE__ */new WeakMap(),
|
|
10
|
+
ParentRectCache = /* @__PURE__ */new WeakMap(),
|
|
11
|
+
DebounceTimers = /* @__PURE__ */new WeakMap(),
|
|
12
|
+
LastChangeTime = /* @__PURE__ */new WeakMap(),
|
|
13
|
+
rAF = typeof window < "u" ? window.requestAnimationFrame : void 0,
|
|
14
|
+
DEBOUNCE_DELAY = 32,
|
|
15
|
+
avoidUpdates = !0,
|
|
16
|
+
queuedUpdates = /* @__PURE__ */new Map();
|
|
17
|
+
function enable() {
|
|
18
|
+
avoidUpdates && (avoidUpdates = !1, queuedUpdates && (queuedUpdates.forEach(function (cb) {
|
|
19
|
+
return cb();
|
|
20
|
+
}), queuedUpdates.clear()));
|
|
21
|
+
}
|
|
22
|
+
if (isClient) if (rAF) {
|
|
23
|
+
let layoutOnAnimationFrame = function () {
|
|
24
|
+
var now = Date.now(),
|
|
25
|
+
timeSinceLastFrame = now - lastFrameAt;
|
|
26
|
+
if (lastFrameAt = now, strategy !== "off") {
|
|
27
|
+
var expectedFrameTime = 16.67,
|
|
28
|
+
hasRecentSyncWork = timeSinceLastFrame > expectedFrameTime * numDroppedFramesUntilPause;
|
|
29
|
+
hasRecentSyncWork || Nodes.forEach(updateLayoutIfChanged);
|
|
30
|
+
}
|
|
31
|
+
rAF(layoutOnAnimationFrame);
|
|
32
|
+
};
|
|
33
|
+
var layoutOnAnimationFrame2 = layoutOnAnimationFrame,
|
|
34
|
+
lastFrameAt = Date.now(),
|
|
35
|
+
numDroppedFramesUntilPause = 2;
|
|
36
|
+
async function updateLayoutIfChanged(node) {
|
|
37
|
+
var nodeRect = node.getBoundingClientRect(),
|
|
38
|
+
parentNode = node.parentElement,
|
|
39
|
+
parentRect = parentNode?.getBoundingClientRect(),
|
|
40
|
+
onLayout = LayoutHandlers.get(node);
|
|
41
|
+
if (typeof onLayout == "function") {
|
|
42
|
+
var cachedRect = NodeRectCache.get(node),
|
|
43
|
+
cachedParentRect = parentNode ? NodeRectCache.get(parentNode) : null;
|
|
44
|
+
if (!cachedRect ||
|
|
45
|
+
// has changed one rect
|
|
46
|
+
!isEqualShallow(cachedRect, nodeRect) && (!cachedParentRect || !isEqualShallow(cachedParentRect, parentRect))) if (NodeRectCache.set(node, nodeRect), parentRect && parentNode && ParentRectCache.set(parentNode, parentRect), avoidUpdates) {
|
|
47
|
+
var event = getElementLayoutEvent(node);
|
|
48
|
+
queuedUpdates.set(node, function () {
|
|
49
|
+
return onLayout(event);
|
|
50
|
+
});
|
|
51
|
+
} else if (strategy === "async") {
|
|
52
|
+
var now = Date.now();
|
|
53
|
+
LastChangeTime.set(node, now);
|
|
54
|
+
var existingTimer = DebounceTimers.get(node);
|
|
55
|
+
existingTimer && clearTimeout(existingTimer);
|
|
56
|
+
var timer = setTimeout(async function () {
|
|
57
|
+
var lastChange = LastChangeTime.get(node) || 0,
|
|
58
|
+
timeSinceChange = Date.now() - lastChange;
|
|
59
|
+
if (timeSinceChange >= DEBOUNCE_DELAY) {
|
|
60
|
+
var event2 = await getElementLayoutEventAsync(node);
|
|
61
|
+
onLayout(event2), DebounceTimers.delete(node);
|
|
62
|
+
} else {
|
|
63
|
+
var remainingDelay = DEBOUNCE_DELAY - timeSinceChange,
|
|
64
|
+
newTimer = setTimeout(async function () {
|
|
65
|
+
var event3 = await getElementLayoutEventAsync(node);
|
|
66
|
+
onLayout(event3), DebounceTimers.delete(node);
|
|
67
|
+
}, remainingDelay);
|
|
68
|
+
DebounceTimers.set(node, newTimer);
|
|
69
|
+
}
|
|
70
|
+
}, DEBOUNCE_DELAY);
|
|
71
|
+
DebounceTimers.set(node, timer);
|
|
72
|
+
} else {
|
|
73
|
+
var event1 = getElementLayoutEvent(node);
|
|
74
|
+
onLayout(event1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
rAF(layoutOnAnimationFrame);
|
|
79
|
+
} else process.env.NODE_ENV === "development" && console.warn("No requestAnimationFrame - please polyfill for onLayout to work correctly");
|
|
80
|
+
var getElementLayoutEvent = function (target) {
|
|
81
|
+
var res = null;
|
|
82
|
+
if (measureLayout(target, null, function (x, y, width, height, left, top) {
|
|
83
|
+
res = {
|
|
84
|
+
nativeEvent: {
|
|
85
|
+
layout: {
|
|
86
|
+
x,
|
|
87
|
+
y,
|
|
88
|
+
width,
|
|
89
|
+
height,
|
|
90
|
+
left,
|
|
91
|
+
top
|
|
92
|
+
},
|
|
93
|
+
target
|
|
94
|
+
},
|
|
95
|
+
timeStamp: Date.now()
|
|
96
|
+
};
|
|
97
|
+
}), !res) throw new Error("\u203C\uFE0F");
|
|
98
|
+
return res;
|
|
99
|
+
},
|
|
100
|
+
measureLayout = function (node, relativeTo, callback) {
|
|
101
|
+
var relativeNode = relativeTo || node?.parentElement;
|
|
102
|
+
if (relativeNode instanceof HTMLElement) {
|
|
103
|
+
var nodeDim = node.getBoundingClientRect(),
|
|
104
|
+
relativeNodeDim = relativeNode.getBoundingClientRect();
|
|
105
|
+
if (relativeNodeDim && nodeDim) {
|
|
106
|
+
var {
|
|
107
|
+
x,
|
|
108
|
+
y,
|
|
109
|
+
width,
|
|
110
|
+
height,
|
|
111
|
+
left,
|
|
112
|
+
top
|
|
113
|
+
} = getRelativeDimensions(nodeDim, relativeNodeDim);
|
|
114
|
+
callback(x, y, width, height, left, top);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
getElementLayoutEventAsync = async function (target) {
|
|
119
|
+
var layout = await measureLayoutAsync(target);
|
|
120
|
+
if (!layout) throw new Error("\u203C\uFE0F");
|
|
121
|
+
return {
|
|
122
|
+
nativeEvent: {
|
|
123
|
+
layout,
|
|
124
|
+
target
|
|
125
|
+
},
|
|
126
|
+
timeStamp: Date.now()
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
measureLayoutAsync = async function (node, relativeTo) {
|
|
130
|
+
var relativeNode = relativeTo || node?.parentElement;
|
|
131
|
+
if (relativeNode instanceof HTMLElement) {
|
|
132
|
+
var [nodeDim, relativeNodeDim] = await Promise.all([node.getBoundingClientRect(), relativeNode.getBoundingClientRect()]);
|
|
133
|
+
if (relativeNodeDim && nodeDim) {
|
|
134
|
+
var {
|
|
135
|
+
x,
|
|
136
|
+
y,
|
|
137
|
+
width,
|
|
138
|
+
height,
|
|
139
|
+
left,
|
|
140
|
+
top
|
|
141
|
+
} = getRelativeDimensions(nodeDim, relativeNodeDim);
|
|
142
|
+
return {
|
|
143
|
+
x,
|
|
144
|
+
y,
|
|
145
|
+
width,
|
|
146
|
+
height,
|
|
147
|
+
left,
|
|
148
|
+
top
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
},
|
|
154
|
+
getRelativeDimensions = function (a, b) {
|
|
155
|
+
var {
|
|
156
|
+
height,
|
|
157
|
+
left,
|
|
158
|
+
top,
|
|
159
|
+
width
|
|
160
|
+
} = a,
|
|
161
|
+
x = left - b.left,
|
|
162
|
+
y = top - b.top;
|
|
163
|
+
return {
|
|
164
|
+
x,
|
|
165
|
+
y,
|
|
166
|
+
width,
|
|
167
|
+
height,
|
|
168
|
+
left,
|
|
169
|
+
top
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
function useElementLayout(ref, onLayout) {
|
|
173
|
+
var _ref_current,
|
|
174
|
+
node = ensureWebElement((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.host);
|
|
175
|
+
node && onLayout && LayoutHandlers.set(node, onLayout), useIsomorphicLayoutEffect(function () {
|
|
176
|
+
var _ref_current2;
|
|
177
|
+
if (onLayout) {
|
|
178
|
+
var node2 = (_ref_current2 = ref.current) === null || _ref_current2 === void 0 ? void 0 : _ref_current2.host;
|
|
179
|
+
if (node2) return LayoutHandlers.set(node2, onLayout), Nodes.add(node2), onLayout(getElementLayoutEvent(node2)), function () {
|
|
180
|
+
Nodes.delete(node2), LayoutHandlers.delete(node2), NodeRectCache.delete(node2);
|
|
181
|
+
var timer = DebounceTimers.get(node2);
|
|
182
|
+
timer && (clearTimeout(timer), DebounceTimers.delete(node2)), LastChangeTime.delete(node2);
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}, [ref, !!onLayout]);
|
|
186
|
+
}
|
|
187
|
+
function ensureWebElement(x) {
|
|
188
|
+
if (!(typeof HTMLElement > "u")) return x instanceof HTMLElement ? x : void 0;
|
|
189
|
+
}
|
|
190
|
+
var getBoundingClientRect = function (node) {
|
|
191
|
+
var _node_getBoundingClientRect;
|
|
192
|
+
if (!(!node || node.nodeType !== 1)) return (_node_getBoundingClientRect = node.getBoundingClientRect) === null || _node_getBoundingClientRect === void 0 ? void 0 : _node_getBoundingClientRect.call(node);
|
|
193
|
+
},
|
|
194
|
+
getRect = function (node) {
|
|
195
|
+
var rect = getBoundingClientRect(node);
|
|
196
|
+
if (rect) {
|
|
197
|
+
var {
|
|
198
|
+
x,
|
|
199
|
+
y,
|
|
200
|
+
top,
|
|
201
|
+
left
|
|
202
|
+
} = rect;
|
|
203
|
+
return {
|
|
204
|
+
x,
|
|
205
|
+
y,
|
|
206
|
+
width: node.offsetWidth,
|
|
207
|
+
height: node.offsetHeight,
|
|
208
|
+
top,
|
|
209
|
+
left
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
export { enable, getElementLayoutEvent, getElementLayoutEventAsync, getRect, measureLayout, measureLayoutAsync, setOnLayoutStrategy, useElementLayout };
|
|
214
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isClient","useIsomorphicLayoutEffect","isEqualShallow","LayoutHandlers","WeakMap","Nodes","Set","strategy","setOnLayoutStrategy","state","NodeRectCache","ParentRectCache","DebounceTimers","LastChangeTime","rAF","window","requestAnimationFrame","DEBOUNCE_DELAY","avoidUpdates","queuedUpdates","Map","enable","forEach","cb","clear","layoutOnAnimationFrame","now","Date","timeSinceLastFrame","lastFrameAt","expectedFrameTime","hasRecentSyncWork","numDroppedFramesUntilPause","updateLayoutIfChanged","layoutOnAnimationFrame2","node","nodeRect","getBoundingClientRect","parentNode","parentElement","parentRect","onLayout","get","cachedRect","cachedParentRect","set","event","getElementLayoutEvent","existingTimer","clearTimeout","timer","setTimeout","lastChange","timeSinceChange","event2","getElementLayoutEventAsync","delete","remainingDelay","newTimer","event3","event1","process","env","NODE_ENV","console","warn","target","res","measureLayout","x","y","width","height","left","top","nativeEvent","layout","timeStamp","Error","relativeTo","callback","relativeNode","HTMLElement","nodeDim","relativeNodeDim","getRelativeDimensions","measureLayoutAsync","Promise","all","a","b","useElementLayout","ref","_ref_current","ensureWebElement","current","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IACF;QAAAC,GAAA;QAAAH;MAAa,IAAKkB,CAAA;MAClBpB,CAAA,GAAAI,IAAA,GAAAiB,CAAA,CAAAjB,IAAe;MAAAH,CAAA,GAAOI,GAAI,GAAAgB,CAE5B,CAAAhB,GAAA;IAA0B,OAC5B;MACFL,CAAG;MACLC,CAAA;MAEAC,KAAS;MACPC,MAAI;MAGJC,IAAA;MACFC;IAEA;EACE;AACA,SAAAiB,gBAAYA,CAAAC,GAAA,EAAAnD,QAAA,EAAwB;EACtC,IAEaoD,YAAW;IAAA1D,IAA+C,GAAA2D,gBAAA,EAAAD,YAAA,GAAAD,GAAA,CAAAG,OAAA,cAAAF,YAAA,uBAAAA,YAAA,CAAAG,IAAA;EACrE7D,IAAA,IAAMM,QAAO,IAAAtC,cAAA,CAAsB0C,GAAA,CAAIV,IAAA,EAAAM,QAAA,GAAAxC,yBAAA;IACvC,IAAKgG,aAAM;IACX,IAAMxD,QAAQ;MACd,IAAOyD,KAAK,GAAG,CAAAD,aAAY,GAAAL,GAAA,CAAAG,OAAa,MAAQ,IAAK,IAAAE,aAAc,KAAK,KAAK,aAAAA,aAAA,CAAAD,IAAA;MAC/E,IAAAE,KAAA,E","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tamagui/use-element-layout",
|
|
3
|
+
"version": "1.129.6-1751237024118",
|
|
4
|
+
"types": "./types/index.d.ts",
|
|
5
|
+
"main": "dist/cjs",
|
|
6
|
+
"module": "dist/esm",
|
|
7
|
+
"files": [
|
|
8
|
+
"src",
|
|
9
|
+
"types",
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tamagui-build",
|
|
14
|
+
"watch": "tamagui-build --watch",
|
|
15
|
+
"lint": "biome check src",
|
|
16
|
+
"lint:fix": "biome check --write src",
|
|
17
|
+
"clean": "tamagui-build clean",
|
|
18
|
+
"clean:build": "tamagui-build clean:build"
|
|
19
|
+
},
|
|
20
|
+
"exports": {
|
|
21
|
+
"./package.json": "./package.json",
|
|
22
|
+
".": {
|
|
23
|
+
"react-native": {
|
|
24
|
+
"import": "./dist/esm/index.native.js",
|
|
25
|
+
"require": "./dist/cjs/index.native.js"
|
|
26
|
+
},
|
|
27
|
+
"types": "./types/index.d.ts",
|
|
28
|
+
"import": "./dist/esm/index.mjs",
|
|
29
|
+
"require": "./dist/cjs/index.cjs",
|
|
30
|
+
"default": "./dist/cjs/index.native.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@tamagui/constants": "1.129.6-1751237024118",
|
|
35
|
+
"@tamagui/is-equal-shallow": "1.129.6-1751237024118"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@tamagui/build": "1.129.6-1751237024118",
|
|
39
|
+
"react": "*"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react": "*"
|
|
47
|
+
}
|
|
48
|
+
}
|