react-zoom-pan-pinch 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +335 -67
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +53 -3
- package/dist/index.esm.js +335 -68
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +40 -0
- package/package.json +1 -1
- package/src/components/transform-component/transform-component.tsx +25 -2
- package/src/constants/state.constants.ts +3 -0
- package/src/core/double-click/double-click.logic.ts +18 -9
- package/src/core/handlers/handlers.utils.ts +89 -2
- package/src/core/instance.core.ts +146 -24
- package/src/core/pan/panning.logic.ts +2 -1
- package/src/core/pan/panning.utils.ts +35 -0
- package/src/core/wheel/wheel.logic.ts +19 -2
- package/src/core/wheel/wheel.utils.ts +44 -2
- package/src/models/context.model.ts +25 -2
- package/src/typings.d.ts +5 -0
- package/src/utils/state.utils.ts +8 -2
- package/src/utils/styles.utils.ts +37 -0
package/dist/index.cjs.js
CHANGED
|
@@ -453,6 +453,34 @@ var isPanningAllowed = function (contextInstance) {
|
|
|
453
453
|
return false;
|
|
454
454
|
return true;
|
|
455
455
|
};
|
|
456
|
+
/**
|
|
457
|
+
* Pointer travel in px up to which a press still counts as a click, not a
|
|
458
|
+
* drag: a pan ending within it aligns instead of flinging, and only a pan
|
|
459
|
+
* beyond it swallows the click that follows (#452).
|
|
460
|
+
*/
|
|
461
|
+
var CLICK_DISTANCE = 5;
|
|
462
|
+
/**
|
|
463
|
+
* Whether a pan moving by (`dx`, `dy`) would push the content further into a
|
|
464
|
+
* bound it already rests on, judged on the dominant axis. With
|
|
465
|
+
* `panning.releaseAtBounds` such a gesture is handed back to the page or the
|
|
466
|
+
* parent (a carousel, page scroll) instead of being claimed (#509).
|
|
467
|
+
*/
|
|
468
|
+
function isPanBlockedAtBounds(contextInstance, dx, dy) {
|
|
469
|
+
var bounds = contextInstance.bounds, setup = contextInstance.setup, state = contextInstance.state;
|
|
470
|
+
if (!bounds || !setup.limitToBounds || (!dx && !dy))
|
|
471
|
+
return false;
|
|
472
|
+
var isHorizontal = Math.abs(dx) >= Math.abs(dy);
|
|
473
|
+
if (isHorizontal ? setup.panning.lockAxisX : setup.panning.lockAxisY) {
|
|
474
|
+
return true;
|
|
475
|
+
}
|
|
476
|
+
var delta = isHorizontal ? dx : dy;
|
|
477
|
+
var position = isHorizontal ? state.positionX : state.positionY;
|
|
478
|
+
var min = isHorizontal ? bounds.minPositionX : bounds.minPositionY;
|
|
479
|
+
var max = isHorizontal ? bounds.maxPositionX : bounds.maxPositionY;
|
|
480
|
+
// Moving the pointer right/down moves the content towards its max bound.
|
|
481
|
+
// Half a pixel of slack: alignment animations settle on float values.
|
|
482
|
+
return delta > 0 ? position >= max - 0.5 : position <= min + 0.5;
|
|
483
|
+
}
|
|
456
484
|
var getPaddingValue = function (contextInstance, size, explicitScale) {
|
|
457
485
|
var setup = contextInstance.setup, state = contextInstance.state;
|
|
458
486
|
var minScale = setup.minScale, disablePadding = setup.disablePadding, centerZoomedOut = setup.centerZoomedOut;
|
|
@@ -791,7 +819,7 @@ function handlePanningEnd(contextInstance, velocityDisabled) {
|
|
|
791
819
|
// A click is not a fling, but it can still land on content left past
|
|
792
820
|
// the bounds — e.g. grabbed mid return animation, which the press
|
|
793
821
|
// cancelled. Finish the return (a no-op inside the bounds).
|
|
794
|
-
if (dx * dx + dy * dy <=
|
|
822
|
+
if (dx * dx + dy * dy <= Math.pow(CLICK_DISTANCE, 2)) {
|
|
795
823
|
handleAlignToBounds(contextInstance);
|
|
796
824
|
return;
|
|
797
825
|
}
|
|
@@ -938,6 +966,7 @@ var initialSetup = {
|
|
|
938
966
|
trackPadPanning: {
|
|
939
967
|
disabled: true,
|
|
940
968
|
velocityDisabled: false,
|
|
969
|
+
speed: 1,
|
|
941
970
|
lockAxisX: false,
|
|
942
971
|
lockAxisY: false,
|
|
943
972
|
activationKeys: [],
|
|
@@ -951,6 +980,8 @@ var initialSetup = {
|
|
|
951
980
|
allowLeftClickPan: true,
|
|
952
981
|
allowMiddleClickPan: true,
|
|
953
982
|
allowRightClickPan: true,
|
|
983
|
+
suppressClickAfterPan: true,
|
|
984
|
+
releaseAtBounds: false,
|
|
954
985
|
activationKeys: [],
|
|
955
986
|
excluded: [],
|
|
956
987
|
},
|
|
@@ -1008,13 +1039,19 @@ var baseClasses = {
|
|
|
1008
1039
|
};
|
|
1009
1040
|
|
|
1010
1041
|
var createState = function (props) {
|
|
1011
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
1042
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1012
1043
|
var minScale = Math.max((_a = props.minScale) !== null && _a !== void 0 ? _a : initialSetup.minScale, 1e-7);
|
|
1013
1044
|
var maxScale = (_b = props.maxScale) !== null && _b !== void 0 ? _b : initialSetup.maxScale;
|
|
1014
1045
|
var rawScale = (_c = props.initialScale) !== null && _c !== void 0 ? _c : initialState.scale;
|
|
1015
1046
|
var scale = Math.min(Math.max(rawScale, minScale), maxScale);
|
|
1016
|
-
|
|
1017
|
-
|
|
1047
|
+
// A named initial position ("center", "right", …) needs the sizes, so it
|
|
1048
|
+
// starts at 0 and `applyNamedInitialPosition` places it once laid out.
|
|
1049
|
+
var positionX = boundLimiter(typeof props.initialPositionX === "number"
|
|
1050
|
+
? props.initialPositionX
|
|
1051
|
+
: initialState.positionX, (_d = props.minPositionX) !== null && _d !== void 0 ? _d : -Infinity, (_e = props.maxPositionX) !== null && _e !== void 0 ? _e : Infinity, props.minPositionX != null || props.maxPositionX != null);
|
|
1052
|
+
var positionY = boundLimiter(typeof props.initialPositionY === "number"
|
|
1053
|
+
? props.initialPositionY
|
|
1054
|
+
: initialState.positionY, (_f = props.minPositionY) !== null && _f !== void 0 ? _f : -Infinity, (_g = props.maxPositionY) !== null && _g !== void 0 ? _g : Infinity, props.minPositionY != null || props.maxPositionY != null);
|
|
1018
1055
|
return {
|
|
1019
1056
|
previousScale: scale,
|
|
1020
1057
|
scale: scale,
|
|
@@ -1164,6 +1201,53 @@ function calculateFitToView(contextInstance, mode, minFitScale, maxFitScale) {
|
|
|
1164
1201
|
scale = checkZoomBounds(scale, setup.minScale, setup.maxScale, 0, false);
|
|
1165
1202
|
return getCenterPosition(scale, wrapperComponent, contentComponent);
|
|
1166
1203
|
}
|
|
1204
|
+
// Share of the free space (wrapper minus scaled content) left before the
|
|
1205
|
+
// content for each named initial position (#349).
|
|
1206
|
+
var NAMED_POSITION_SHARE = {
|
|
1207
|
+
left: 0,
|
|
1208
|
+
top: 0,
|
|
1209
|
+
center: 0.5,
|
|
1210
|
+
right: 1,
|
|
1211
|
+
bottom: 1,
|
|
1212
|
+
};
|
|
1213
|
+
function hasNamedInitialPosition(contextInstance) {
|
|
1214
|
+
var _a = contextInstance.props, initialPositionX = _a.initialPositionX, initialPositionY = _a.initialPositionY;
|
|
1215
|
+
return (typeof initialPositionX === "string" || typeof initialPositionY === "string");
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Replaces each axis of `target` whose `initialPositionX/Y` is named
|
|
1219
|
+
* (`"right"`, `"center"`, `"top"`…) with the position that puts the content
|
|
1220
|
+
* there at `target.scale`. Numeric axes are left as they are.
|
|
1221
|
+
*/
|
|
1222
|
+
function applyNamedInitialPosition(contextInstance, target) {
|
|
1223
|
+
var wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent, props = contextInstance.props;
|
|
1224
|
+
var initialPositionX = props.initialPositionX, initialPositionY = props.initialPositionY;
|
|
1225
|
+
if (!wrapperComponent || !contentComponent)
|
|
1226
|
+
return target;
|
|
1227
|
+
var place = function (name, wrapperSize, contentSize) { return (wrapperSize - contentSize * target.scale) * NAMED_POSITION_SHARE[name]; };
|
|
1228
|
+
return {
|
|
1229
|
+
scale: target.scale,
|
|
1230
|
+
positionX: typeof initialPositionX === "string"
|
|
1231
|
+
? place(initialPositionX, wrapperComponent.clientWidth, contentComponent.offsetWidth)
|
|
1232
|
+
: target.positionX,
|
|
1233
|
+
positionY: typeof initialPositionY === "string"
|
|
1234
|
+
? place(initialPositionY, wrapperComponent.clientHeight, contentComponent.offsetHeight)
|
|
1235
|
+
: target.positionY,
|
|
1236
|
+
};
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* The scale `resetTransform` returns to: the fitted one with `fitOnInit`,
|
|
1240
|
+
* otherwise `initialScale` (clamped to min/max).
|
|
1241
|
+
*/
|
|
1242
|
+
function getResetScale(contextInstance) {
|
|
1243
|
+
var fitOnInit = contextInstance.setup.fitOnInit;
|
|
1244
|
+
if (fitOnInit) {
|
|
1245
|
+
var fitted = calculateFitToView(contextInstance, fitOnInit === "cover" ? "cover" : "contain");
|
|
1246
|
+
if (fitted)
|
|
1247
|
+
return fitted.scale;
|
|
1248
|
+
}
|
|
1249
|
+
return createState(contextInstance.props).scale;
|
|
1250
|
+
}
|
|
1167
1251
|
function resetTransformations(contextInstance, animationTime, animationType, onResetTransformation) {
|
|
1168
1252
|
var setup = contextInstance.setup, wrapperComponent = contextInstance.wrapperComponent, contentComponent = contextInstance.contentComponent;
|
|
1169
1253
|
var limitToBounds = setup.limitToBounds, centerOnInit = setup.centerOnInit, fitOnInit = setup.fitOnInit;
|
|
@@ -1174,8 +1258,9 @@ function resetTransformations(contextInstance, animationTime, animationType, onR
|
|
|
1174
1258
|
// With `fitOnInit` the initial layout is the fitted one, so that is what a
|
|
1175
1259
|
// reset returns to (#252).
|
|
1176
1260
|
if (fitOnInit) {
|
|
1177
|
-
var
|
|
1178
|
-
if (
|
|
1261
|
+
var fit_1 = calculateFitToView(contextInstance, fitOnInit === "cover" ? "cover" : "contain");
|
|
1262
|
+
if (fit_1) {
|
|
1263
|
+
var fitted = applyNamedInitialPosition(contextInstance, fit_1);
|
|
1179
1264
|
if (scale === fitted.scale &&
|
|
1180
1265
|
positionX === fitted.positionX &&
|
|
1181
1266
|
positionY === fitted.positionY) {
|
|
@@ -1192,6 +1277,14 @@ function resetTransformations(contextInstance, animationTime, animationType, onR
|
|
|
1192
1277
|
targetPositionX = centered.positionX;
|
|
1193
1278
|
targetPositionY = centered.positionY;
|
|
1194
1279
|
}
|
|
1280
|
+
// Named initial positions win over the centring on their own axis (#349).
|
|
1281
|
+
var named = applyNamedInitialPosition(contextInstance, {
|
|
1282
|
+
scale: initialTransformation.scale,
|
|
1283
|
+
positionX: targetPositionX,
|
|
1284
|
+
positionY: targetPositionY,
|
|
1285
|
+
});
|
|
1286
|
+
targetPositionX = named.positionX;
|
|
1287
|
+
targetPositionY = named.positionY;
|
|
1195
1288
|
var newBounds = calculateBounds(contextInstance, initialTransformation.scale);
|
|
1196
1289
|
var boundedPositions = getMouseBoundedPosition(targetPositionX, targetPositionY, newBounds, limitToBounds, 0, 0, wrapperComponent);
|
|
1197
1290
|
var newState = {
|
|
@@ -1605,6 +1698,39 @@ var cancelTimeout = function (timeout) {
|
|
|
1605
1698
|
var roundScaleForTransform = function (scale) {
|
|
1606
1699
|
return Number.parseFloat(scale.toFixed(8));
|
|
1607
1700
|
};
|
|
1701
|
+
var STYLE_MARKER = "data-react-zoom-pan-pinch";
|
|
1702
|
+
/**
|
|
1703
|
+
* Adds the library stylesheet once per root the wrapper renders into: the
|
|
1704
|
+
* document `<head>`, or the shadow root itself (#371), where a stylesheet in
|
|
1705
|
+
* the head never applies. `nonce` is set on the `<style>` so a CSP with
|
|
1706
|
+
* `style-src 'nonce-…'` accepts it (#403). A `<style>` already holding the
|
|
1707
|
+
* same CSS is reused, so several viewers (or a re-mount) add one copy.
|
|
1708
|
+
*/
|
|
1709
|
+
function injectStylesheet(wrapper, css, nonce) {
|
|
1710
|
+
if (!css || typeof wrapper.getRootNode !== "function")
|
|
1711
|
+
return;
|
|
1712
|
+
var doc = wrapper.ownerDocument;
|
|
1713
|
+
var root = wrapper.getRootNode();
|
|
1714
|
+
// Duck-typed: a ShadowRoot from another window fails `instanceof`.
|
|
1715
|
+
var isShadowRoot = root.nodeType === 11 && "host" in root;
|
|
1716
|
+
var container = isShadowRoot
|
|
1717
|
+
? root
|
|
1718
|
+
: doc.head;
|
|
1719
|
+
if (!container)
|
|
1720
|
+
return;
|
|
1721
|
+
var existing = container.querySelectorAll("style[".concat(STYLE_MARKER, "]"));
|
|
1722
|
+
for (var index = 0; index < existing.length; index += 1) {
|
|
1723
|
+
if (existing[index].textContent === css)
|
|
1724
|
+
return;
|
|
1725
|
+
}
|
|
1726
|
+
var style = doc.createElement("style");
|
|
1727
|
+
style.setAttribute(STYLE_MARKER, "");
|
|
1728
|
+
if (nonce)
|
|
1729
|
+
style.setAttribute("nonce", nonce);
|
|
1730
|
+
style.textContent = css;
|
|
1731
|
+
// Appended, like style-inject did before (the bundle used to add it at load).
|
|
1732
|
+
container.appendChild(style);
|
|
1733
|
+
}
|
|
1608
1734
|
var getTransformStyles = function (x, y, scale) {
|
|
1609
1735
|
// Standard translate prevents blurry svg on the safari
|
|
1610
1736
|
var s = roundScaleForTransform(scale);
|
|
@@ -1921,9 +2047,10 @@ function handleSizeChange(contextInstance) {
|
|
|
1921
2047
|
|
|
1922
2048
|
var isWheelAllowed = function (contextInstance, event) {
|
|
1923
2049
|
var _a = contextInstance.setup.wheel, disabled = _a.disabled, wheelDisabled = _a.wheelDisabled, touchPadDisabled = _a.touchPadDisabled, excluded = _a.excluded;
|
|
1924
|
-
var isInitialized = contextInstance.isInitialized
|
|
2050
|
+
var isInitialized = contextInstance.isInitialized;
|
|
1925
2051
|
var target = event.target;
|
|
1926
|
-
|
|
2052
|
+
// Zooming mid-drag is allowed (#543): `handleWheelZoom` re-anchors the pan.
|
|
2053
|
+
var isAllowed = isInitialized && !disabled && target;
|
|
1927
2054
|
if (!isAllowed)
|
|
1928
2055
|
return false;
|
|
1929
2056
|
// A purely horizontal wheel/swipe (Magic Mouse, trackpad) carries no zoom
|
|
@@ -1953,6 +2080,10 @@ var isWheelPanningAllowed = function (contextInstance, event) {
|
|
|
1953
2080
|
if (disabled || trackPadPanning.disabled || event.ctrlKey) {
|
|
1954
2081
|
return false;
|
|
1955
2082
|
}
|
|
2083
|
+
// A drag owns the position; a wheel pan on top of it would be undone by
|
|
2084
|
+
// the next pointer move.
|
|
2085
|
+
if (contextInstance.isPanning)
|
|
2086
|
+
return false;
|
|
1956
2087
|
var isAllowed = isWheelAllowed(contextInstance, event);
|
|
1957
2088
|
// Cannot execute at the same time as wheel zoom
|
|
1958
2089
|
if (isAllowed)
|
|
@@ -1966,6 +2097,36 @@ var isWheelPanningAllowed = function (contextInstance, event) {
|
|
|
1966
2097
|
return false;
|
|
1967
2098
|
return true;
|
|
1968
2099
|
};
|
|
2100
|
+
// px per line for `deltaMode === 1` (Firefox with a mouse wheel), close to
|
|
2101
|
+
// what browsers scroll a page per line.
|
|
2102
|
+
var WHEEL_LINE_HEIGHT = 16;
|
|
2103
|
+
/**
|
|
2104
|
+
* The distance in px a wheel event pans by (#500):
|
|
2105
|
+
* - line and page deltas (`deltaMode` 1/2) become pixels, so a wheel that
|
|
2106
|
+
* reports "3 lines" moves 48px instead of 3px;
|
|
2107
|
+
* - Shift turns a vertical wheel horizontal where the browser does not do it
|
|
2108
|
+
* already (a browser that does reports it as `deltaX`);
|
|
2109
|
+
* - `speed` scales the result.
|
|
2110
|
+
*/
|
|
2111
|
+
function getWheelPanDelta(event, wrapperComponent, speed) {
|
|
2112
|
+
var unitX = 1;
|
|
2113
|
+
var unitY = 1;
|
|
2114
|
+
if (event.deltaMode === 1) {
|
|
2115
|
+
unitX = WHEEL_LINE_HEIGHT;
|
|
2116
|
+
unitY = WHEEL_LINE_HEIGHT;
|
|
2117
|
+
}
|
|
2118
|
+
else if (event.deltaMode === 2) {
|
|
2119
|
+
unitX = wrapperComponent.clientWidth;
|
|
2120
|
+
unitY = wrapperComponent.clientHeight;
|
|
2121
|
+
}
|
|
2122
|
+
var x = event.deltaX * unitX;
|
|
2123
|
+
var y = event.deltaY * unitY;
|
|
2124
|
+
if (event.shiftKey && !x) {
|
|
2125
|
+
x = y;
|
|
2126
|
+
y = 0;
|
|
2127
|
+
}
|
|
2128
|
+
return { x: x * speed, y: y * speed };
|
|
2129
|
+
}
|
|
1969
2130
|
var getDeltaY = function (event) {
|
|
1970
2131
|
if (event) {
|
|
1971
2132
|
return event.deltaY < 0 ? 1 : -1;
|
|
@@ -2119,9 +2280,12 @@ var handleWheelZoom = function (contextInstance, event) {
|
|
|
2119
2280
|
event.preventDefault();
|
|
2120
2281
|
}
|
|
2121
2282
|
event.stopPropagation();
|
|
2283
|
+
var isPanning = contextInstance.isPanning;
|
|
2122
2284
|
var delta = getDelta(event, null);
|
|
2123
2285
|
var zoomStep = smooth ? step * Math.abs(event.deltaY) : step;
|
|
2124
|
-
|
|
2286
|
+
// Mid-drag the scale stays inside min/max: the overshoot would need the
|
|
2287
|
+
// settle animation, which cannot run while the pointer owns the position.
|
|
2288
|
+
var newScale = handleCalculateWheelZoom(contextInstance, delta, zoomStep, !event.ctrlKey || isPanning);
|
|
2125
2289
|
// if scale not change
|
|
2126
2290
|
if (scale === newScale)
|
|
2127
2291
|
return;
|
|
@@ -2132,6 +2296,15 @@ var handleWheelZoom = function (contextInstance, event) {
|
|
|
2132
2296
|
var _b = handleCalculateZoomPositions(contextInstance, mousePosition.x, mousePosition.y, newScale, bounds, isLimitedToBounds), x = _b.x, y = _b.y;
|
|
2133
2297
|
contextInstance.previousWheelEvent = event;
|
|
2134
2298
|
contextInstance.setState(newScale, x, y);
|
|
2299
|
+
// Zoom during a drag (#543): the pan maps pointer → position through
|
|
2300
|
+
// `startCoords`, taken at the old scale. Re-anchor it at the zoomed state,
|
|
2301
|
+
// or the next move snaps the content back. The velocity sample from before
|
|
2302
|
+
// the zoom would read the jump as a fling, so drop it too.
|
|
2303
|
+
if (isPanning) {
|
|
2304
|
+
handlePanningSetup(contextInstance, event);
|
|
2305
|
+
contextInstance.lastMousePosition = null;
|
|
2306
|
+
contextInstance.velocity = null;
|
|
2307
|
+
}
|
|
2135
2308
|
handleCallback(getContext(contextInstance), event, onWheel);
|
|
2136
2309
|
handleCallback(getContext(contextInstance), event, onZoom);
|
|
2137
2310
|
};
|
|
@@ -2142,8 +2315,12 @@ var handleWheelStop = function (contextInstance, event) {
|
|
|
2142
2315
|
contextInstance.wheelAnimationTimer = setTimeout(function () {
|
|
2143
2316
|
if (!contextInstance.mounted)
|
|
2144
2317
|
return;
|
|
2145
|
-
handleAlignToScaleBounds(contextInstance, event.x, event.y);
|
|
2146
2318
|
contextInstance.wheelAnimationTimer = null;
|
|
2319
|
+
// Mid-drag the pan end aligns (and flushes a pending resize) instead:
|
|
2320
|
+
// an animation now would fight the pointer (#543).
|
|
2321
|
+
if (contextInstance.isPanning)
|
|
2322
|
+
return;
|
|
2323
|
+
handleAlignToScaleBounds(contextInstance, event.x, event.y);
|
|
2147
2324
|
contextInstance.flushResizeAlignment();
|
|
2148
2325
|
}, wheelAnimationTime);
|
|
2149
2326
|
// Wheel stop event
|
|
@@ -2299,12 +2476,12 @@ var handleDoubleClickResetMode = function (contextInstance, event) {
|
|
|
2299
2476
|
});
|
|
2300
2477
|
handleDoubleClickStop(contextInstance, event);
|
|
2301
2478
|
};
|
|
2302
|
-
function getDoubleClickScale(mode
|
|
2303
|
-
if (mode === "toggle") {
|
|
2304
|
-
return scale === 1 ? 1 : -1;
|
|
2305
|
-
}
|
|
2479
|
+
function getDoubleClickScale(mode) {
|
|
2306
2480
|
return mode === "zoomOut" ? -1 : 1;
|
|
2307
2481
|
}
|
|
2482
|
+
// Scales closer than this count as "at the reset scale": animations and fits
|
|
2483
|
+
// land on float values.
|
|
2484
|
+
var RESET_SCALE_TOLERANCE = 1e-3;
|
|
2308
2485
|
function handleDoubleClick(contextInstance, event) {
|
|
2309
2486
|
var setup = contextInstance.setup, doubleClickStopEventTimer = contextInstance.doubleClickStopEventTimer, state = contextInstance.state, contentComponent = contextInstance.contentComponent;
|
|
2310
2487
|
var scale = state.scale;
|
|
@@ -2317,9 +2494,19 @@ function handleDoubleClick(contextInstance, event) {
|
|
|
2317
2494
|
if (mode === "reset") {
|
|
2318
2495
|
return handleDoubleClickResetMode(contextInstance, event);
|
|
2319
2496
|
}
|
|
2497
|
+
// `toggle` (#125): at the reset scale (`initialScale`, or the fitted one
|
|
2498
|
+
// with `fitOnInit`) zoom in by `step`; anywhere else go back to the reset
|
|
2499
|
+
// state. It used to compare against 1, so with another initial scale the
|
|
2500
|
+
// first double click zoomed out, and the way back only stepped out.
|
|
2501
|
+
if (mode === "toggle") {
|
|
2502
|
+
var resetScale = getResetScale(contextInstance);
|
|
2503
|
+
if (Math.abs(scale - resetScale) > RESET_SCALE_TOLERANCE) {
|
|
2504
|
+
return handleDoubleClickResetMode(contextInstance, event);
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2320
2507
|
if (!contentComponent)
|
|
2321
2508
|
return console.error("No ContentComponent found");
|
|
2322
|
-
var delta = getDoubleClickScale(mode
|
|
2509
|
+
var delta = getDoubleClickScale(mode);
|
|
2323
2510
|
var newScale = handleCalculateButtonZoom(contextInstance, delta, step);
|
|
2324
2511
|
// stop execution when scale didn't change
|
|
2325
2512
|
if (scale === newScale)
|
|
@@ -2373,6 +2560,10 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
2373
2560
|
this.isWheelPanning = false;
|
|
2374
2561
|
this.startCoords = null;
|
|
2375
2562
|
this.panStartPosition = null;
|
|
2563
|
+
// Pointer travel of the running mouse/touch pan: whether it moved at all
|
|
2564
|
+
// (the first move decides `releaseAtBounds`, #509) and whether it went
|
|
2565
|
+
// past the click distance (the click after it is swallowed, #452).
|
|
2566
|
+
this.panGesture = null;
|
|
2376
2567
|
this.lastTouch = null;
|
|
2377
2568
|
// pinch helpers
|
|
2378
2569
|
this.isPinching = false;
|
|
@@ -2502,6 +2693,7 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
2502
2693
|
wrapper.removeEventListener("touchstart", _this.onTouchPanningStart, passive);
|
|
2503
2694
|
wrapper.removeEventListener("touchmove", _this.onTouchPanning, passive);
|
|
2504
2695
|
wrapper.removeEventListener("touchend", _this.onTouchPanningStop, passive);
|
|
2696
|
+
wrapper.removeEventListener("scroll", _this.onWrapperScroll, passive);
|
|
2505
2697
|
};
|
|
2506
2698
|
this.handleInitializeWrapperEvents = function (wrapper) {
|
|
2507
2699
|
// Zooming events on wrapper
|
|
@@ -2512,12 +2704,31 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
2512
2704
|
wrapper.addEventListener("touchstart", _this.onTouchPanningStart, passive);
|
|
2513
2705
|
wrapper.addEventListener("touchmove", _this.onTouchPanning, passive);
|
|
2514
2706
|
wrapper.addEventListener("touchend", _this.onTouchPanningStop, passive);
|
|
2707
|
+
wrapper.addEventListener("scroll", _this.onWrapperScroll, passive);
|
|
2708
|
+
};
|
|
2709
|
+
// The wrapper clips with `overflow: hidden`, but the browser still scrolls
|
|
2710
|
+
// it to reveal a focused input (the virtual keyboard on mobile) or for
|
|
2711
|
+
// `scrollIntoView`. Nothing in the transform knows about that offset, so
|
|
2712
|
+
// the content stayed shifted and could not be panned back (#280, #477).
|
|
2713
|
+
// Fold the scroll into the position instead: the target stays in view and
|
|
2714
|
+
// the state matches what is on screen.
|
|
2715
|
+
this.onWrapperScroll = function () {
|
|
2716
|
+
var wrapper = _this.wrapperComponent;
|
|
2717
|
+
if (!wrapper)
|
|
2718
|
+
return;
|
|
2719
|
+
var scrollLeft = wrapper.scrollLeft, scrollTop = wrapper.scrollTop;
|
|
2720
|
+
if (!scrollLeft && !scrollTop)
|
|
2721
|
+
return;
|
|
2722
|
+
wrapper.scrollLeft = 0;
|
|
2723
|
+
wrapper.scrollTop = 0;
|
|
2724
|
+
var _a = _this.state, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
|
|
2725
|
+
_this.setState(scale, positionX - scrollLeft, positionY - scrollTop);
|
|
2515
2726
|
};
|
|
2516
2727
|
this.handleInitialize = function () {
|
|
2517
2728
|
var _a = _this.setup, centerOnInit = _a.centerOnInit, fitOnInit = _a.fitOnInit;
|
|
2518
2729
|
_this.applyTransformation();
|
|
2519
2730
|
_this.onInitCallbacks.forEach(function (callback) { return callback(getContext(_this)); });
|
|
2520
|
-
if (centerOnInit || fitOnInit) {
|
|
2731
|
+
if (centerOnInit || fitOnInit || hasNamedInitialPosition(_this)) {
|
|
2521
2732
|
var applied = _this.applyInitialLayout();
|
|
2522
2733
|
// Content without a size yet (an image still loading) gets its layout
|
|
2523
2734
|
// applied again by `onSizeChange` once it has one. Once a real layout
|
|
@@ -2610,17 +2821,19 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
2610
2821
|
this.onWheelPanning = function (event) {
|
|
2611
2822
|
var onPanning = _this.props.onPanning;
|
|
2612
2823
|
var trackPadPanning = _this.setup.trackPadPanning;
|
|
2613
|
-
var lockAxisX = trackPadPanning.lockAxisX, lockAxisY = trackPadPanning.lockAxisY;
|
|
2824
|
+
var lockAxisX = trackPadPanning.lockAxisX, lockAxisY = trackPadPanning.lockAxisY, speed = trackPadPanning.speed;
|
|
2825
|
+
var wrapper = _this.wrapperComponent;
|
|
2614
2826
|
_this.syncModifierKeys(event);
|
|
2615
2827
|
var isAllowed = isWheelPanningAllowed(_this, event);
|
|
2616
|
-
if (!isAllowed)
|
|
2828
|
+
if (!isAllowed || !wrapper)
|
|
2617
2829
|
return;
|
|
2618
2830
|
if (event.cancelable) {
|
|
2619
2831
|
event.preventDefault();
|
|
2620
2832
|
}
|
|
2621
2833
|
event.stopPropagation();
|
|
2622
|
-
var
|
|
2623
|
-
var
|
|
2834
|
+
var delta = getWheelPanDelta(event, wrapper, speed);
|
|
2835
|
+
var deltaX = lockAxisX ? 0 : delta.x;
|
|
2836
|
+
var deltaY = lockAxisY ? 0 : delta.y;
|
|
2624
2837
|
if (!deltaX && !deltaY)
|
|
2625
2838
|
return;
|
|
2626
2839
|
var _a = _this.setup.autoAlignment, sizeX = _a.sizeX, sizeY = _a.sizeY;
|
|
@@ -2665,6 +2878,7 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
2665
2878
|
event.stopPropagation();
|
|
2666
2879
|
handleCancelAnimation(_this);
|
|
2667
2880
|
handlePanningStart(_this, event);
|
|
2881
|
+
_this.startPanGesture(event.clientX, event.clientY);
|
|
2668
2882
|
_this.lockTextSelection();
|
|
2669
2883
|
_this.focusForKeyboard();
|
|
2670
2884
|
handleCallback(getContext(_this), event, onPanningStart);
|
|
@@ -2687,6 +2901,10 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
2687
2901
|
var keysPressed = _this.isPressingKeys(_this.setup.panning.activationKeys);
|
|
2688
2902
|
if (!keysPressed)
|
|
2689
2903
|
return;
|
|
2904
|
+
if (_this.trackPanGesture(event.clientX, event.clientY)) {
|
|
2905
|
+
_this.onPanningStop(event);
|
|
2906
|
+
return;
|
|
2907
|
+
}
|
|
2690
2908
|
if (event.cancelable) {
|
|
2691
2909
|
event.preventDefault();
|
|
2692
2910
|
}
|
|
@@ -2695,15 +2913,73 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
2695
2913
|
handleCallback(getContext(_this), event, onPanning);
|
|
2696
2914
|
};
|
|
2697
2915
|
this.onPanningStop = function (event) {
|
|
2698
|
-
var
|
|
2916
|
+
var _a;
|
|
2917
|
+
var _b = _this.setup.panning, velocityDisabled = _b.velocityDisabled, suppressClickAfterPan = _b.suppressClickAfterPan;
|
|
2699
2918
|
var onPanningStop = _this.props.onPanningStop;
|
|
2700
2919
|
if (_this.isPanning) {
|
|
2920
|
+
var isDrag = !!((_a = _this.panGesture) === null || _a === void 0 ? void 0 : _a.isDrag);
|
|
2921
|
+
_this.panGesture = null;
|
|
2701
2922
|
_this.unlockTextSelection();
|
|
2702
2923
|
handlePanningEnd(_this, velocityDisabled);
|
|
2703
2924
|
handleCallback(getContext(_this), event, onPanningStop);
|
|
2704
2925
|
_this.flushResizeAlignment();
|
|
2926
|
+
// Only a mouseup is followed by a click on the content; a released or
|
|
2927
|
+
// cancelled gesture (mousemove, mouseleave, touch) is not.
|
|
2928
|
+
if (isDrag && suppressClickAfterPan && event.type === "mouseup") {
|
|
2929
|
+
_this.suppressNextClick();
|
|
2930
|
+
}
|
|
2705
2931
|
}
|
|
2706
2932
|
};
|
|
2933
|
+
this.startPanGesture = function (clientX, clientY) {
|
|
2934
|
+
_this.panGesture = {
|
|
2935
|
+
startX: clientX,
|
|
2936
|
+
startY: clientY,
|
|
2937
|
+
hasMoved: false,
|
|
2938
|
+
isDrag: false,
|
|
2939
|
+
};
|
|
2940
|
+
};
|
|
2941
|
+
// Records the pointer travel of the running pan. Returns true when this is
|
|
2942
|
+
// the first move, it heads into a bound the content already rests on and
|
|
2943
|
+
// `releaseAtBounds` is on: the caller then ends the pan without claiming
|
|
2944
|
+
// the event, so the page scrolls or a parent takes the drag (#509).
|
|
2945
|
+
this.trackPanGesture = function (clientX, clientY) {
|
|
2946
|
+
var gesture = _this.panGesture;
|
|
2947
|
+
if (!gesture)
|
|
2948
|
+
return false;
|
|
2949
|
+
var dx = clientX - gesture.startX;
|
|
2950
|
+
var dy = clientY - gesture.startY;
|
|
2951
|
+
if (!dx && !dy)
|
|
2952
|
+
return false;
|
|
2953
|
+
var isFirstMove = !gesture.hasMoved;
|
|
2954
|
+
gesture.hasMoved = true;
|
|
2955
|
+
if (dx * dx + dy * dy > Math.pow(CLICK_DISTANCE, 2))
|
|
2956
|
+
gesture.isDrag = true;
|
|
2957
|
+
return (isFirstMove &&
|
|
2958
|
+
_this.setup.panning.releaseAtBounds &&
|
|
2959
|
+
isPanBlockedAtBounds(_this, dx, dy));
|
|
2960
|
+
};
|
|
2961
|
+
// The browser fires `click` right after `mouseup`, in the same task, so a
|
|
2962
|
+
// capture listener on the window that removes itself on the next tick
|
|
2963
|
+
// swallows exactly that click and nothing later (#452).
|
|
2964
|
+
this.suppressNextClick = function () {
|
|
2965
|
+
var _a;
|
|
2966
|
+
var wrapper = _this.wrapperComponent;
|
|
2967
|
+
var win = (_a = wrapper === null || wrapper === void 0 ? void 0 : wrapper.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
|
|
2968
|
+
if (!wrapper || !win)
|
|
2969
|
+
return;
|
|
2970
|
+
var swallow = function (event) {
|
|
2971
|
+
var path = typeof event.composedPath === "function" ? event.composedPath() : [];
|
|
2972
|
+
var isInside = path.includes(wrapper) || wrapper.contains(event.target);
|
|
2973
|
+
if (!isInside)
|
|
2974
|
+
return;
|
|
2975
|
+
event.preventDefault();
|
|
2976
|
+
event.stopPropagation();
|
|
2977
|
+
};
|
|
2978
|
+
win.addEventListener("click", swallow, { capture: true, once: true });
|
|
2979
|
+
win.setTimeout(function () {
|
|
2980
|
+
win.removeEventListener("click", swallow, { capture: true });
|
|
2981
|
+
}, 0);
|
|
2982
|
+
};
|
|
2707
2983
|
/// ///////
|
|
2708
2984
|
// Pinch
|
|
2709
2985
|
/// ///////
|
|
@@ -2770,6 +3046,7 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
2770
3046
|
return;
|
|
2771
3047
|
handleCancelAnimation(_this);
|
|
2772
3048
|
handlePanningStart(_this, event);
|
|
3049
|
+
_this.startPanGesture(touches[0].clientX, touches[0].clientY);
|
|
2773
3050
|
_this.lockTextSelection();
|
|
2774
3051
|
_this.focusForKeyboard();
|
|
2775
3052
|
handleCallback(getContext(_this), event, onPanningStart);
|
|
@@ -2788,11 +3065,16 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
2788
3065
|
var isAllowed = isPanningAllowed(_this);
|
|
2789
3066
|
if (!isAllowed)
|
|
2790
3067
|
return;
|
|
3068
|
+
var touch = event.touches[0];
|
|
3069
|
+
// Not cancelling the first touchmove is what lets the browser scroll.
|
|
3070
|
+
if (_this.trackPanGesture(touch.clientX, touch.clientY)) {
|
|
3071
|
+
_this.onPanningStop(event);
|
|
3072
|
+
return;
|
|
3073
|
+
}
|
|
2791
3074
|
if (event.cancelable) {
|
|
2792
3075
|
event.preventDefault();
|
|
2793
3076
|
}
|
|
2794
3077
|
event.stopPropagation();
|
|
2795
|
-
var touch = event.touches[0];
|
|
2796
3078
|
handlePanning(_this, touch.clientX, touch.clientY, exports.DeviceType.TOUCH);
|
|
2797
3079
|
handleCallback(getContext(_this), event, onPanning);
|
|
2798
3080
|
}
|
|
@@ -2832,6 +3114,7 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
2832
3114
|
if (_this.isPanning) {
|
|
2833
3115
|
_this.isPanning = false;
|
|
2834
3116
|
_this.startCoords = null;
|
|
3117
|
+
_this.panGesture = null;
|
|
2835
3118
|
}
|
|
2836
3119
|
_this.unlockTextSelection();
|
|
2837
3120
|
_this.flushResizeAlignment();
|
|
@@ -2939,24 +3222,30 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
2939
3222
|
/// ///////
|
|
2940
3223
|
// `fitOnInit` wins over `centerOnInit` (a fit is always centred). Falls
|
|
2941
3224
|
// back to centring while the content has no size yet; `onSizeChange`
|
|
2942
|
-
// re-runs this once it does.
|
|
2943
|
-
// whether
|
|
3225
|
+
// re-runs this once it does. A named `initialPositionX/Y` then places its
|
|
3226
|
+
// own axis (#349). Returns whether both boxes had a size, i.e. whether
|
|
3227
|
+
// this was a real initial layout.
|
|
2944
3228
|
this.applyInitialLayout = function () {
|
|
2945
|
-
var
|
|
2946
|
-
var
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
3229
|
+
var _a = _this.setup, fitOnInit = _a.fitOnInit, centerOnInit = _a.centerOnInit;
|
|
3230
|
+
var _b = _this, wrapperComponent = _b.wrapperComponent, contentComponent = _b.contentComponent;
|
|
3231
|
+
if (!wrapperComponent || !contentComponent)
|
|
3232
|
+
return false;
|
|
3233
|
+
var hasSizes = wrapperComponent.clientWidth > 0 &&
|
|
2950
3234
|
wrapperComponent.clientHeight > 0 &&
|
|
2951
3235
|
(contentComponent.offsetWidth > 0 || contentComponent.offsetHeight > 0);
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
3236
|
+
var _c = _this.state, scale = _c.scale, positionX = _c.positionX, positionY = _c.positionY;
|
|
3237
|
+
var target = { scale: scale, positionX: positionX, positionY: positionY };
|
|
3238
|
+
var fitted = fitOnInit
|
|
3239
|
+
? calculateFitToView(_this, fitOnInit === "cover" ? "cover" : "contain")
|
|
3240
|
+
: null;
|
|
3241
|
+
if (fitted) {
|
|
3242
|
+
target = fitted;
|
|
2958
3243
|
}
|
|
2959
|
-
|
|
3244
|
+
else if (fitOnInit || centerOnInit) {
|
|
3245
|
+
target = getCenterPosition(scale, wrapperComponent, contentComponent);
|
|
3246
|
+
}
|
|
3247
|
+
var placed = applyNamedInitialPosition(_this, target);
|
|
3248
|
+
_this.setState(placed.scale, placed.positionX, placed.positionY);
|
|
2960
3249
|
return hasSizes;
|
|
2961
3250
|
};
|
|
2962
3251
|
this.setCenter = function () {
|
|
@@ -3465,40 +3754,14 @@ var MiniMap = function (_a) {
|
|
|
3465
3754
|
return (jsxRuntime.jsxs("div", __assign({}, rest, { ref: mainRef, style: containerStyle, className: "rzpp-mini-map ".concat(rest.className || "").trim() }, { children: [jsxRuntime.jsx("div", __assign({ style: wrapperStyles, ref: wrapperRef, className: "rzpp-minimap-wrapper ".concat(wrapperClassName || "").trim() }, { children: children })), jsxRuntime.jsx("svg", __assign({ className: "rzpp-minimap-mask", style: maskStyles, width: width, height: height, viewBox: "0 0 ".concat(width, " ").concat(height), "aria-hidden": "true" }, { children: jsxRuntime.jsx("path", { ref: maskPathRef, fill: maskColor, fillRule: "evenodd", d: "M0 0H".concat(width, "V").concat(height, "H0Z") }) })), jsxRuntime.jsx("div", { className: "rzpp-minimap-preview ".concat(previewClassName || "").trim(), ref: previewRef, style: __assign(__assign(__assign({}, previewStyles), { borderColor: borderColor }), previewStyle) })] })));
|
|
3466
3755
|
};
|
|
3467
3756
|
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
var insertAt = ref.insertAt;
|
|
3471
|
-
|
|
3472
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
3473
|
-
|
|
3474
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
3475
|
-
var style = document.createElement('style');
|
|
3476
|
-
style.type = 'text/css';
|
|
3477
|
-
|
|
3478
|
-
if (insertAt === 'top') {
|
|
3479
|
-
if (head.firstChild) {
|
|
3480
|
-
head.insertBefore(style, head.firstChild);
|
|
3481
|
-
} else {
|
|
3482
|
-
head.appendChild(style);
|
|
3483
|
-
}
|
|
3484
|
-
} else {
|
|
3485
|
-
head.appendChild(style);
|
|
3486
|
-
}
|
|
3487
|
-
|
|
3488
|
-
if (style.styleSheet) {
|
|
3489
|
-
style.styleSheet.cssText = css;
|
|
3490
|
-
} else {
|
|
3491
|
-
style.appendChild(document.createTextNode(css));
|
|
3492
|
-
}
|
|
3493
|
-
}
|
|
3494
|
-
|
|
3495
|
-
var css_248z = ".transform-component-module_wrapper__SPB86 {\n position: relative;\n width: -moz-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: fit-content;\n overflow: hidden;\n -webkit-touch-callout: none; /* iOS Safari */\n /* Text stays selectable (#467); the instance applies an inline lock\n only while a pan gesture is active. */\n margin: 0;\n padding: 0;\n transform: translate3d(0, 0, 0);\n}\n.transform-component-module_content__FBWxo {\n display: flex;\n flex-wrap: wrap;\n width: -moz-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: fit-content;\n margin: 0;\n padding: 0;\n transform-origin: 0% 0%;\n}\n.transform-component-module_content__FBWxo img {\n pointer-events: none;\n}\n.transform-component-module_infiniteGrid__Z-aP3 {\n position: absolute;\n inset: 0;\n pointer-events: none;\n background-image: radial-gradient(\n circle,\n rgba(0, 0, 0, 0.12) 1px,\n transparent 1px\n );\n background-size: 20px 20px;\n background-position: 0 0;\n}\n";
|
|
3496
|
-
var styles = {"wrapper":"transform-component-module_wrapper__SPB86","content":"transform-component-module_content__FBWxo","infiniteGrid":"transform-component-module_infiniteGrid__Z-aP3"};
|
|
3497
|
-
styleInject(css_248z);
|
|
3757
|
+
var transformComponent_module = {"wrapper":"transform-component-module_wrapper__SPB86","content":"transform-component-module_content__FBWxo","infiniteGrid":"transform-component-module_infiniteGrid__Z-aP3"};
|
|
3758
|
+
var stylesheet$1=".transform-component-module_wrapper__SPB86 {\n position: relative;\n width: -moz-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: fit-content;\n overflow: hidden;\n -webkit-touch-callout: none; /* iOS Safari */\n /* Text stays selectable (#467); the instance applies an inline lock\n only while a pan gesture is active. */\n margin: 0;\n padding: 0;\n transform: translate3d(0, 0, 0);\n}\n.transform-component-module_content__FBWxo {\n display: flex;\n flex-wrap: wrap;\n width: -moz-fit-content;\n width: fit-content;\n height: -moz-fit-content;\n height: fit-content;\n margin: 0;\n padding: 0;\n transform-origin: 0% 0%;\n}\n.transform-component-module_content__FBWxo img {\n pointer-events: none;\n}\n.transform-component-module_infiniteGrid__Z-aP3 {\n position: absolute;\n inset: 0;\n pointer-events: none;\n background-image: radial-gradient(\n circle,\n rgba(0, 0, 0, 0.12) 1px,\n transparent 1px\n );\n background-size: 20px 20px;\n background-position: 0 0;\n}\n";
|
|
3498
3759
|
|
|
3760
|
+
var styles = transformComponent_module;
|
|
3761
|
+
var stylesheet = stylesheet$1;
|
|
3499
3762
|
var TransformComponent = function (_a) {
|
|
3500
3763
|
var _b;
|
|
3501
|
-
var children = _a.children, _c = _a.wrapperClass, wrapperClass = _c === void 0 ? "" : _c, _d = _a.contentClass, contentClass = _d === void 0 ? "" : _d, wrapperStyle = _a.wrapperStyle, contentStyle = _a.contentStyle, _e = _a.wrapperProps, wrapperProps = _e === void 0 ? {} : _e, _f = _a.contentProps, contentProps = _f === void 0 ? {} : _f, _g = _a.infinite, infinite = _g === void 0 ? false : _g;
|
|
3764
|
+
var children = _a.children, _c = _a.wrapperClass, wrapperClass = _c === void 0 ? "" : _c, _d = _a.contentClass, contentClass = _d === void 0 ? "" : _d, wrapperStyle = _a.wrapperStyle, contentStyle = _a.contentStyle, _e = _a.wrapperProps, wrapperProps = _e === void 0 ? {} : _e, _f = _a.contentProps, contentProps = _f === void 0 ? {} : _f, _g = _a.infinite, infinite = _g === void 0 ? false : _g, nonce = _a.nonce, _h = _a.disableStyleInjection, disableStyleInjection = _h === void 0 ? false : _h;
|
|
3502
3765
|
var instance = React.useContext(Context);
|
|
3503
3766
|
var init = instance.init, cleanupWindowEvents = instance.cleanupWindowEvents;
|
|
3504
3767
|
var wrapperRef = React.useRef(null);
|
|
@@ -3510,6 +3773,10 @@ var TransformComponent = function (_a) {
|
|
|
3510
3773
|
useIsomorphicLayoutEffect(function () {
|
|
3511
3774
|
var wrapper = wrapperRef.current;
|
|
3512
3775
|
var content = contentRef.current;
|
|
3776
|
+
// Before `init` measures anything: the sizes depend on these rules.
|
|
3777
|
+
if (wrapper !== null && !disableStyleInjection) {
|
|
3778
|
+
injectStylesheet(wrapper, stylesheet, nonce);
|
|
3779
|
+
}
|
|
3513
3780
|
if (wrapper !== null && content !== null && init) {
|
|
3514
3781
|
init === null || init === void 0 ? void 0 : init(wrapper, content);
|
|
3515
3782
|
}
|
|
@@ -3799,6 +4066,7 @@ exports.Virtualize = Virtualize;
|
|
|
3799
4066
|
exports.getCenterPosition = getCenterPosition;
|
|
3800
4067
|
exports.getMatrixTransformStyles = getMatrixTransformStyles;
|
|
3801
4068
|
exports.getTransformStyles = getTransformStyles;
|
|
4069
|
+
exports.injectStylesheet = injectStylesheet;
|
|
3802
4070
|
exports.roundScaleForTransform = roundScaleForTransform;
|
|
3803
4071
|
exports.useControls = useControls;
|
|
3804
4072
|
exports.useTransformComponent = useTransformComponent;
|