react-zoom-pan-pinch 3.5.0 → 3.6.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 +36 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.esm.js +36 -5
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -725,6 +725,10 @@ var initialSetup = {
|
|
|
725
725
|
equalToMove: true,
|
|
726
726
|
},
|
|
727
727
|
};
|
|
728
|
+
var baseClasses = {
|
|
729
|
+
wrapperClass: "react-transform-wrapper",
|
|
730
|
+
contentClass: "react-transform-component",
|
|
731
|
+
};
|
|
728
732
|
|
|
729
733
|
var createState = function (props) {
|
|
730
734
|
var _a, _b, _c, _d;
|
|
@@ -956,9 +960,10 @@ function makePassiveEventOption() {
|
|
|
956
960
|
}
|
|
957
961
|
}
|
|
958
962
|
|
|
963
|
+
var matchPrefix = ".".concat(baseClasses.wrapperClass);
|
|
959
964
|
var isExcludedNode = function (node, excluded) {
|
|
960
965
|
return excluded.some(function (exclude) {
|
|
961
|
-
return node.matches("".concat(exclude, ", .").concat(exclude, ", ").concat(exclude, " *, .").concat(exclude, " *"));
|
|
966
|
+
return node.matches("".concat(matchPrefix, " ").concat(exclude, ", ").concat(matchPrefix, " .").concat(exclude, ", ").concat(matchPrefix, " ").concat(exclude, " *, ").concat(matchPrefix, " .").concat(exclude, " *"));
|
|
962
967
|
});
|
|
963
968
|
};
|
|
964
969
|
var cancelTimeout = function (timeout) {
|
|
@@ -1850,6 +1855,19 @@ var MiniMap = function (_a) {
|
|
|
1850
1855
|
var mainRef = React.useRef(null);
|
|
1851
1856
|
var wrapperRef = React.useRef(null);
|
|
1852
1857
|
var previewRef = React.useRef(null);
|
|
1858
|
+
var getViewportSize = React.useCallback(function () {
|
|
1859
|
+
if (instance.wrapperComponent) {
|
|
1860
|
+
var rect = instance.wrapperComponent.getBoundingClientRect();
|
|
1861
|
+
return {
|
|
1862
|
+
width: rect.width,
|
|
1863
|
+
height: rect.height
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
return {
|
|
1867
|
+
width: 0,
|
|
1868
|
+
height: 0
|
|
1869
|
+
};
|
|
1870
|
+
}, [instance.wrapperComponent]);
|
|
1853
1871
|
var getContentSize = React.useCallback(function () {
|
|
1854
1872
|
if (instance.contentComponent) {
|
|
1855
1873
|
var rect = instance.contentComponent.getBoundingClientRect();
|
|
@@ -1908,7 +1926,7 @@ var MiniMap = function (_a) {
|
|
|
1908
1926
|
mainRef.current.style.height = "".concat(miniSize.height, "px");
|
|
1909
1927
|
}
|
|
1910
1928
|
if (previewRef.current) {
|
|
1911
|
-
var size =
|
|
1929
|
+
var size = getViewportSize();
|
|
1912
1930
|
var scale = computeMiniMapScale();
|
|
1913
1931
|
var previewScale = scale * (1 / instance.transformState.scale);
|
|
1914
1932
|
var transform = instance.handleTransformStyles(-instance.transformState.positionX * previewScale, -instance.transformState.positionY * previewScale, 1);
|
|
@@ -2000,8 +2018,8 @@ var TransformComponent = function (_a) {
|
|
|
2000
2018
|
cleanupWindowEvents === null || cleanupWindowEvents === void 0 ? void 0 : cleanupWindowEvents();
|
|
2001
2019
|
};
|
|
2002
2020
|
}, []);
|
|
2003
|
-
return (React__default["default"].createElement("div", __assign({}, wrapperProps, { ref: wrapperRef, className: "
|
|
2004
|
-
React__default["default"].createElement("div", __assign({}, contentProps, { ref: contentRef, className: "
|
|
2021
|
+
return (React__default["default"].createElement("div", __assign({}, wrapperProps, { ref: wrapperRef, className: "".concat(baseClasses.wrapperClass, " ").concat(styles.wrapper, " ").concat(wrapperClass), style: wrapperStyle }),
|
|
2022
|
+
React__default["default"].createElement("div", __assign({}, contentProps, { ref: contentRef, className: "".concat(baseClasses.contentClass, " ").concat(styles.content, " ").concat(contentClass), style: contentStyle }), children)));
|
|
2005
2023
|
};
|
|
2006
2024
|
|
|
2007
2025
|
var useTransformContext = function () {
|
|
@@ -2053,7 +2071,20 @@ var useTransformEffect = function (callback) {
|
|
|
2053
2071
|
|
|
2054
2072
|
function useTransformComponent(callback) {
|
|
2055
2073
|
var libraryContext = useTransformContext();
|
|
2056
|
-
|
|
2074
|
+
var _a = React.useState(callback(getState(libraryContext))), transformRender = _a[0], setTransformRender = _a[1];
|
|
2075
|
+
React.useEffect(function () {
|
|
2076
|
+
var mounted = true;
|
|
2077
|
+
var unmount = libraryContext.onChange(function (ref) {
|
|
2078
|
+
if (mounted) {
|
|
2079
|
+
setTransformRender(callback(getState(ref.instance)));
|
|
2080
|
+
}
|
|
2081
|
+
});
|
|
2082
|
+
return function () {
|
|
2083
|
+
unmount();
|
|
2084
|
+
mounted = false;
|
|
2085
|
+
};
|
|
2086
|
+
}, [callback, libraryContext]);
|
|
2087
|
+
return transformRender;
|
|
2057
2088
|
}
|
|
2058
2089
|
|
|
2059
2090
|
exports.Context = Context;
|