@fumadocs/base-ui 16.8.5 → 16.8.7
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/css/generated/shared.css +13 -9
- package/dist/components/image-zoom.d.ts +1 -1
- package/dist/components/image-zoom.js +1 -1
- package/dist/components/toc/clerk.js +67 -55
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/layouts/home/slots/header.d.ts +1 -1
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/Controlled.d.ts → react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/controlled.d.ts} +2 -7
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/Controlled.js → react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/controlled.js} +32 -8
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/index.d.ts +2 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/uncontrolled.d.ts +7 -0
- package/dist/node_modules/.pnpm/{react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/Uncontrolled.js → react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/uncontrolled.js} +2 -2
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/adjust-svg-ids.js +53 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/compute-positioned-style.js +25 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/element-tests.js +12 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/get-div-img-style.js +45 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/get-img-alt.js +8 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/get-img-object-fit-style.js +55 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/get-img-regular-style.js +21 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/get-img-src.js +14 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/get-modal-img-transform.js +22 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/get-scale.js +27 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/get-style-ghost.js +31 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/get-style-modal-img.js +75 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/get-target-dimension.js +4 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/parse-position.js +7 -0
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.4_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils/test-has-scalable-src.js +5 -0
- package/dist/style.css +20 -13
- package/package.json +9 -9
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/Uncontrolled.d.ts +0 -7
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/icons.js +0 -24
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/index.d.ts +0 -2
- package/dist/node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils.js +0 -372
|
@@ -1,372 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/react-medium-image-zoom@5.4.3_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/react-medium-image-zoom/dist/utils.js
|
|
2
|
-
function isElement(el) {
|
|
3
|
-
if (typeof Element === "undefined") return false;
|
|
4
|
-
return el instanceof Element;
|
|
5
|
-
}
|
|
6
|
-
const testElType = (type, el) => isElement(el) && el.tagName.toUpperCase() === type;
|
|
7
|
-
const testDiv = (el) => testElType("DIV", el) || testElType("SPAN", el);
|
|
8
|
-
const testImg = (el) => testElType("IMG", el);
|
|
9
|
-
const testImgLoaded = (el) => el.complete && el.naturalHeight !== 0;
|
|
10
|
-
const testSvg = (el) => testElType("SVG", el);
|
|
11
|
-
const getScaleToWindow = ({ height, offset, width }) => Math.min((window.innerWidth - offset * 2) / width, (window.innerHeight - offset * 2) / height);
|
|
12
|
-
const getScaleToWindowMax = ({ containerHeight, containerWidth, offset, targetHeight, targetWidth }) => {
|
|
13
|
-
const scale = getScaleToWindow({
|
|
14
|
-
height: targetHeight,
|
|
15
|
-
offset,
|
|
16
|
-
width: targetWidth
|
|
17
|
-
});
|
|
18
|
-
const ratio = targetWidth > targetHeight ? targetWidth / containerWidth : targetHeight / containerHeight;
|
|
19
|
-
return scale > 1 ? ratio : scale * ratio;
|
|
20
|
-
};
|
|
21
|
-
const getScale = ({ containerHeight, containerWidth, hasScalableSrc, offset, targetHeight, targetWidth }) => {
|
|
22
|
-
if (containerHeight === 0 || containerWidth === 0) return 1;
|
|
23
|
-
return !hasScalableSrc && targetHeight !== 0 && targetWidth !== 0 ? getScaleToWindowMax({
|
|
24
|
-
containerHeight,
|
|
25
|
-
containerWidth,
|
|
26
|
-
offset,
|
|
27
|
-
targetHeight,
|
|
28
|
-
targetWidth
|
|
29
|
-
}) : getScaleToWindow({
|
|
30
|
-
height: containerHeight,
|
|
31
|
-
offset,
|
|
32
|
-
width: containerWidth
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
const URL_REGEX = /url(?:\(['"]?)(?<url>.*?)(?:['"]?\))/;
|
|
36
|
-
const getImgSrc = (imgEl) => {
|
|
37
|
-
if (imgEl !== null) {
|
|
38
|
-
if (testImg(imgEl)) return imgEl.currentSrc === "" ? void 0 : imgEl.currentSrc;
|
|
39
|
-
else if (testDiv(imgEl)) {
|
|
40
|
-
const { backgroundImage: bgImg } = window.getComputedStyle(imgEl);
|
|
41
|
-
if (bgImg !== "") return URL_REGEX.exec(bgImg)?.[1];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const getImgAlt = (imgEl) => {
|
|
46
|
-
if (imgEl !== null) if (testImg(imgEl)) return imgEl.alt;
|
|
47
|
-
else return imgEl.getAttribute("aria-label") ?? void 0;
|
|
48
|
-
};
|
|
49
|
-
const getImgRegularStyle = ({ containerHeight, containerLeft, containerTop, containerWidth, hasScalableSrc, offset, targetHeight, targetWidth }) => {
|
|
50
|
-
const scale = getScale({
|
|
51
|
-
containerHeight,
|
|
52
|
-
containerWidth,
|
|
53
|
-
hasScalableSrc,
|
|
54
|
-
offset,
|
|
55
|
-
targetHeight,
|
|
56
|
-
targetWidth
|
|
57
|
-
});
|
|
58
|
-
return {
|
|
59
|
-
top: containerTop,
|
|
60
|
-
left: containerLeft,
|
|
61
|
-
width: containerWidth * scale,
|
|
62
|
-
height: containerHeight * scale,
|
|
63
|
-
transform: `translate(0,0) scale(${1 / scale})`
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
const parsePosition = ({ position, relativeNum }) => {
|
|
67
|
-
const positionNum = parseFloat(position);
|
|
68
|
-
return position.endsWith("%") ? relativeNum * positionNum / 100 : positionNum;
|
|
69
|
-
};
|
|
70
|
-
const getImgObjectFitStyle = ({ containerHeight, containerLeft, containerTop, containerWidth, hasScalableSrc, objectFit: objectFitParam, objectPosition, offset, targetHeight, targetWidth }) => {
|
|
71
|
-
let resolvedObjectFit = objectFitParam;
|
|
72
|
-
if (resolvedObjectFit === "scale-down") if (targetWidth <= containerWidth && targetHeight <= containerHeight) resolvedObjectFit = "none";
|
|
73
|
-
else resolvedObjectFit = "contain";
|
|
74
|
-
if (resolvedObjectFit === "cover" || resolvedObjectFit === "contain") {
|
|
75
|
-
const widthRatio = containerWidth / targetWidth;
|
|
76
|
-
const heightRatio = containerHeight / targetHeight;
|
|
77
|
-
const ratio = resolvedObjectFit === "cover" ? Math.max(widthRatio, heightRatio) : Math.min(widthRatio, heightRatio);
|
|
78
|
-
const [posLeft = "50%", posTop = "50%"] = objectPosition.split(" ");
|
|
79
|
-
const posX = parsePosition({
|
|
80
|
-
position: posLeft,
|
|
81
|
-
relativeNum: containerWidth - targetWidth * ratio
|
|
82
|
-
});
|
|
83
|
-
const posY = parsePosition({
|
|
84
|
-
position: posTop,
|
|
85
|
-
relativeNum: containerHeight - targetHeight * ratio
|
|
86
|
-
});
|
|
87
|
-
const scale = getScale({
|
|
88
|
-
containerHeight: targetHeight * ratio,
|
|
89
|
-
containerWidth: targetWidth * ratio,
|
|
90
|
-
hasScalableSrc,
|
|
91
|
-
offset,
|
|
92
|
-
targetHeight,
|
|
93
|
-
targetWidth
|
|
94
|
-
});
|
|
95
|
-
return {
|
|
96
|
-
top: containerTop + posY,
|
|
97
|
-
left: containerLeft + posX,
|
|
98
|
-
width: targetWidth * ratio * scale,
|
|
99
|
-
height: targetHeight * ratio * scale,
|
|
100
|
-
transform: `translate(0,0) scale(${1 / scale})`
|
|
101
|
-
};
|
|
102
|
-
} else if (resolvedObjectFit === "none") {
|
|
103
|
-
const [posLeft = "50%", posTop = "50%"] = objectPosition.split(" ");
|
|
104
|
-
const posX = parsePosition({
|
|
105
|
-
position: posLeft,
|
|
106
|
-
relativeNum: containerWidth - targetWidth
|
|
107
|
-
});
|
|
108
|
-
const posY = parsePosition({
|
|
109
|
-
position: posTop,
|
|
110
|
-
relativeNum: containerHeight - targetHeight
|
|
111
|
-
});
|
|
112
|
-
const scale = getScale({
|
|
113
|
-
containerHeight: targetHeight,
|
|
114
|
-
containerWidth: targetWidth,
|
|
115
|
-
hasScalableSrc,
|
|
116
|
-
offset,
|
|
117
|
-
targetHeight,
|
|
118
|
-
targetWidth
|
|
119
|
-
});
|
|
120
|
-
return {
|
|
121
|
-
top: containerTop + posY,
|
|
122
|
-
left: containerLeft + posX,
|
|
123
|
-
width: targetWidth * scale,
|
|
124
|
-
height: targetHeight * scale,
|
|
125
|
-
transform: `translate(0,0) scale(${1 / scale})`
|
|
126
|
-
};
|
|
127
|
-
} else if (resolvedObjectFit === "fill") {
|
|
128
|
-
const widthRatio = containerWidth / targetWidth;
|
|
129
|
-
const heightRatio = containerHeight / targetHeight;
|
|
130
|
-
const ratio = Math.max(widthRatio, heightRatio);
|
|
131
|
-
const scale = getScale({
|
|
132
|
-
containerHeight: targetHeight * ratio,
|
|
133
|
-
containerWidth: targetWidth * ratio,
|
|
134
|
-
hasScalableSrc,
|
|
135
|
-
offset,
|
|
136
|
-
targetHeight,
|
|
137
|
-
targetWidth
|
|
138
|
-
});
|
|
139
|
-
return {
|
|
140
|
-
width: containerWidth * scale,
|
|
141
|
-
height: containerHeight * scale,
|
|
142
|
-
transform: `translate(0,0) scale(${1 / scale})`
|
|
143
|
-
};
|
|
144
|
-
} else return {};
|
|
145
|
-
};
|
|
146
|
-
const getDivImgStyle = ({ backgroundPosition, backgroundSize, containerHeight, containerLeft, containerTop, containerWidth, hasScalableSrc, offset, targetHeight, targetWidth }) => {
|
|
147
|
-
if (backgroundSize === "cover" || backgroundSize === "contain") {
|
|
148
|
-
const widthRatio = containerWidth / targetWidth;
|
|
149
|
-
const heightRatio = containerHeight / targetHeight;
|
|
150
|
-
const ratio = backgroundSize === "cover" ? Math.max(widthRatio, heightRatio) : Math.min(widthRatio, heightRatio);
|
|
151
|
-
const [posLeft = "50%", posTop = "50%"] = backgroundPosition.split(" ");
|
|
152
|
-
const posX = parsePosition({
|
|
153
|
-
position: posLeft,
|
|
154
|
-
relativeNum: containerWidth - targetWidth * ratio
|
|
155
|
-
});
|
|
156
|
-
const posY = parsePosition({
|
|
157
|
-
position: posTop,
|
|
158
|
-
relativeNum: containerHeight - targetHeight * ratio
|
|
159
|
-
});
|
|
160
|
-
const scale = getScale({
|
|
161
|
-
containerHeight: targetHeight * ratio,
|
|
162
|
-
containerWidth: targetWidth * ratio,
|
|
163
|
-
hasScalableSrc,
|
|
164
|
-
offset,
|
|
165
|
-
targetHeight,
|
|
166
|
-
targetWidth
|
|
167
|
-
});
|
|
168
|
-
return {
|
|
169
|
-
top: containerTop + posY,
|
|
170
|
-
left: containerLeft + posX,
|
|
171
|
-
width: targetWidth * ratio * scale,
|
|
172
|
-
height: targetHeight * ratio * scale,
|
|
173
|
-
transform: `translate(0,0) scale(${1 / scale})`
|
|
174
|
-
};
|
|
175
|
-
} else if (backgroundSize === "auto") {
|
|
176
|
-
const [posLeft = "50%", posTop = "50%"] = backgroundPosition.split(" ");
|
|
177
|
-
const posX = parsePosition({
|
|
178
|
-
position: posLeft,
|
|
179
|
-
relativeNum: containerWidth - targetWidth
|
|
180
|
-
});
|
|
181
|
-
const posY = parsePosition({
|
|
182
|
-
position: posTop,
|
|
183
|
-
relativeNum: containerHeight - targetHeight
|
|
184
|
-
});
|
|
185
|
-
const scale = getScale({
|
|
186
|
-
containerHeight: targetHeight,
|
|
187
|
-
containerWidth: targetWidth,
|
|
188
|
-
hasScalableSrc,
|
|
189
|
-
offset,
|
|
190
|
-
targetHeight,
|
|
191
|
-
targetWidth
|
|
192
|
-
});
|
|
193
|
-
return {
|
|
194
|
-
top: containerTop + posY,
|
|
195
|
-
left: containerLeft + posX,
|
|
196
|
-
width: targetWidth * scale,
|
|
197
|
-
height: targetHeight * scale,
|
|
198
|
-
transform: `translate(0,0) scale(${1 / scale})`
|
|
199
|
-
};
|
|
200
|
-
} else {
|
|
201
|
-
const [sizeW = "50%", sizeH = "50%"] = backgroundSize.split(" ");
|
|
202
|
-
const sizeWidth = parsePosition({
|
|
203
|
-
position: sizeW,
|
|
204
|
-
relativeNum: containerWidth
|
|
205
|
-
});
|
|
206
|
-
const sizeHeight = parsePosition({
|
|
207
|
-
position: sizeH,
|
|
208
|
-
relativeNum: containerHeight
|
|
209
|
-
});
|
|
210
|
-
const widthRatio = sizeWidth / targetWidth;
|
|
211
|
-
const heightRatio = sizeHeight / targetHeight;
|
|
212
|
-
const ratio = Math.min(widthRatio, heightRatio);
|
|
213
|
-
const [posLeft = "50%", posTop = "50%"] = backgroundPosition.split(" ");
|
|
214
|
-
const posX = parsePosition({
|
|
215
|
-
position: posLeft,
|
|
216
|
-
relativeNum: containerWidth - targetWidth * ratio
|
|
217
|
-
});
|
|
218
|
-
const posY = parsePosition({
|
|
219
|
-
position: posTop,
|
|
220
|
-
relativeNum: containerHeight - targetHeight * ratio
|
|
221
|
-
});
|
|
222
|
-
const scale = getScale({
|
|
223
|
-
containerHeight: targetHeight * ratio,
|
|
224
|
-
containerWidth: targetWidth * ratio,
|
|
225
|
-
hasScalableSrc,
|
|
226
|
-
offset,
|
|
227
|
-
targetHeight,
|
|
228
|
-
targetWidth
|
|
229
|
-
});
|
|
230
|
-
return {
|
|
231
|
-
top: containerTop + posY,
|
|
232
|
-
left: containerLeft + posX,
|
|
233
|
-
width: targetWidth * ratio * scale,
|
|
234
|
-
height: targetHeight * ratio * scale,
|
|
235
|
-
transform: `translate(0,0) scale(${1 / scale})`
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
const SRC_SVG_REGEX = /\.svg$/i;
|
|
240
|
-
const getStyleModalImg = ({ hasZoomImg, imgSrc, isSvg, isZoomed, loadedImgEl, offset, shouldRefresh, targetEl }) => {
|
|
241
|
-
const hasScalableSrc = isSvg || imgSrc?.slice(0, 18) === "data:image/svg+xml" || hasZoomImg || imgSrc !== void 0 && SRC_SVG_REGEX.test(imgSrc);
|
|
242
|
-
const imgRect = targetEl.getBoundingClientRect();
|
|
243
|
-
const targetElComputedStyle = window.getComputedStyle(targetEl);
|
|
244
|
-
const isDivImg = loadedImgEl != null && testDiv(targetEl);
|
|
245
|
-
const isImgObjectFit = loadedImgEl != null && !isDivImg;
|
|
246
|
-
const targetHeight = loadedImgEl != null && loadedImgEl.naturalHeight !== 0 ? loadedImgEl.naturalHeight : imgRect.height;
|
|
247
|
-
const targetWidth = loadedImgEl != null && loadedImgEl.naturalWidth !== 0 ? loadedImgEl.naturalWidth : imgRect.width;
|
|
248
|
-
const styleImgRegular = getImgRegularStyle({
|
|
249
|
-
containerHeight: imgRect.height,
|
|
250
|
-
containerLeft: imgRect.left,
|
|
251
|
-
containerTop: imgRect.top,
|
|
252
|
-
containerWidth: imgRect.width,
|
|
253
|
-
hasScalableSrc,
|
|
254
|
-
offset,
|
|
255
|
-
targetHeight,
|
|
256
|
-
targetWidth
|
|
257
|
-
});
|
|
258
|
-
const styleImgObjectFit = isImgObjectFit ? getImgObjectFitStyle({
|
|
259
|
-
containerHeight: imgRect.height,
|
|
260
|
-
containerLeft: imgRect.left,
|
|
261
|
-
containerTop: imgRect.top,
|
|
262
|
-
containerWidth: imgRect.width,
|
|
263
|
-
hasScalableSrc,
|
|
264
|
-
objectFit: targetElComputedStyle.objectFit,
|
|
265
|
-
objectPosition: targetElComputedStyle.objectPosition,
|
|
266
|
-
offset,
|
|
267
|
-
targetHeight,
|
|
268
|
-
targetWidth
|
|
269
|
-
}) : void 0;
|
|
270
|
-
const styleDivImg = isDivImg ? getDivImgStyle({
|
|
271
|
-
backgroundPosition: targetElComputedStyle.backgroundPosition,
|
|
272
|
-
backgroundSize: targetElComputedStyle.backgroundSize,
|
|
273
|
-
containerHeight: imgRect.height,
|
|
274
|
-
containerLeft: imgRect.left,
|
|
275
|
-
containerTop: imgRect.top,
|
|
276
|
-
containerWidth: imgRect.width,
|
|
277
|
-
hasScalableSrc,
|
|
278
|
-
offset,
|
|
279
|
-
targetHeight,
|
|
280
|
-
targetWidth
|
|
281
|
-
}) : void 0;
|
|
282
|
-
const style = {
|
|
283
|
-
...styleImgRegular,
|
|
284
|
-
...styleImgObjectFit,
|
|
285
|
-
...styleDivImg
|
|
286
|
-
};
|
|
287
|
-
if (isZoomed) {
|
|
288
|
-
const viewportX = window.innerWidth / 2;
|
|
289
|
-
const viewportY = window.innerHeight / 2;
|
|
290
|
-
const childCenterX = parseFloat(String(style.left ?? 0)) + parseFloat(String(style.width ?? 0)) / 2;
|
|
291
|
-
const childCenterY = parseFloat(String(style.top ?? 0)) + parseFloat(String(style.height ?? 0)) / 2;
|
|
292
|
-
const translateX = viewportX - childCenterX;
|
|
293
|
-
const translateY = viewportY - childCenterY;
|
|
294
|
-
if (shouldRefresh) style.transitionDuration = "0.01ms";
|
|
295
|
-
style.transform = `translate(${translateX}px,${translateY}px) scale(1)`;
|
|
296
|
-
}
|
|
297
|
-
return style;
|
|
298
|
-
};
|
|
299
|
-
const getStyleGhost = (imgEl) => {
|
|
300
|
-
if (imgEl == null) return {};
|
|
301
|
-
if (testSvg(imgEl)) {
|
|
302
|
-
const { parentElement: parentEl } = imgEl;
|
|
303
|
-
const rect = imgEl.getBoundingClientRect();
|
|
304
|
-
if (parentEl == null) return {
|
|
305
|
-
height: rect.height,
|
|
306
|
-
left: rect.left,
|
|
307
|
-
width: rect.width,
|
|
308
|
-
top: rect.top
|
|
309
|
-
};
|
|
310
|
-
else {
|
|
311
|
-
const parentRect = parentEl.getBoundingClientRect();
|
|
312
|
-
return {
|
|
313
|
-
height: rect.height,
|
|
314
|
-
left: parentRect.left - rect.left,
|
|
315
|
-
top: parentRect.top - rect.top,
|
|
316
|
-
width: rect.width
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
} else return {
|
|
320
|
-
height: imgEl.offsetHeight,
|
|
321
|
-
left: imgEl.offsetLeft,
|
|
322
|
-
width: imgEl.offsetWidth,
|
|
323
|
-
top: imgEl.offsetTop
|
|
324
|
-
};
|
|
325
|
-
};
|
|
326
|
-
const adjustSvgIDs = (svgEl) => {
|
|
327
|
-
const newIdSuffix = "-zoom";
|
|
328
|
-
const attrs = [
|
|
329
|
-
"clip-path",
|
|
330
|
-
"fill",
|
|
331
|
-
"mask",
|
|
332
|
-
"marker-start",
|
|
333
|
-
"marker-mid",
|
|
334
|
-
"marker-end"
|
|
335
|
-
];
|
|
336
|
-
const idMap = /* @__PURE__ */ new Map();
|
|
337
|
-
if (svgEl.hasAttribute("id")) {
|
|
338
|
-
const { id: oldId } = svgEl;
|
|
339
|
-
const newId = oldId + newIdSuffix;
|
|
340
|
-
idMap.set(oldId, newId);
|
|
341
|
-
const svgNode = svgEl;
|
|
342
|
-
svgNode.id = newId;
|
|
343
|
-
}
|
|
344
|
-
svgEl.querySelectorAll("[id]").forEach((el) => {
|
|
345
|
-
const { id: oldId } = el;
|
|
346
|
-
const newId = oldId + newIdSuffix;
|
|
347
|
-
idMap.set(oldId, newId);
|
|
348
|
-
const node = el;
|
|
349
|
-
node.id = newId;
|
|
350
|
-
});
|
|
351
|
-
idMap.forEach((newId, oldId) => {
|
|
352
|
-
const urlOldID = `url(#${oldId})`;
|
|
353
|
-
const urlNewID = `url(#${newId})`;
|
|
354
|
-
const attrsQuery = attrs.map((attr) => `[${attr}="${urlOldID}"]`).join(", ");
|
|
355
|
-
svgEl.querySelectorAll(attrsQuery).forEach((usedEl) => {
|
|
356
|
-
attrs.forEach((attr) => {
|
|
357
|
-
if (usedEl.getAttribute(attr) === urlOldID) usedEl.setAttribute(attr, urlNewID);
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
svgEl.querySelectorAll("style").forEach((styleEl) => {
|
|
362
|
-
idMap.forEach((newId, oldId) => {
|
|
363
|
-
const { textContent } = styleEl;
|
|
364
|
-
if (textContent !== "") {
|
|
365
|
-
const styleNode = styleEl;
|
|
366
|
-
styleNode.textContent = textContent.replaceAll(`#${oldId}`, `#${newId}`);
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
});
|
|
370
|
-
};
|
|
371
|
-
//#endregion
|
|
372
|
-
export { adjustSvgIDs, getImgAlt, getImgSrc, getStyleGhost, getStyleModalImg, testDiv, testImg, testImgLoaded, testSvg };
|