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.d.ts
CHANGED
|
@@ -233,6 +233,10 @@ type ReactZoomPanPinchComponentHelpers = {
|
|
|
233
233
|
setComponents: (wrapper: HTMLDivElement, content: HTMLDivElement) => void;
|
|
234
234
|
};
|
|
235
235
|
type LibrarySetup = Pick<ReactZoomPanPinchProps, "minPositionX" | "maxPositionX" | "minPositionY" | "maxPositionY"> & DeepNonNullable<Omit<ReactZoomPanPinchProps, "ref" | "initialScale" | "initialPositionX" | "initialPositionY" | "minPositionX" | "maxPositionX" | "minPositionY" | "maxPositionY" | "children" | "defaultPositionX" | "defaultPositionY" | "defaultScale" | "wrapperClass" | "contentClass" | "onWheelStart" | "onWheel" | "onWheelStop" | "onPanningStart" | "onPanning" | "onPanningStop" | "onPinchingStart" | "onPinching" | "onPinchingStop" | "onZoomStart" | "onZoom" | "onZoomStop" | "onTransformed" | "onInit" | "customTransform">>;
|
|
236
|
+
type ReactZoomPanPinchBaseClasses = {
|
|
237
|
+
wrapperClass: string;
|
|
238
|
+
contentClass: string;
|
|
239
|
+
};
|
|
236
240
|
|
|
237
241
|
type SizeType = {
|
|
238
242
|
width: number;
|
|
@@ -298,4 +302,4 @@ declare const getTransformStyles: (x: number, y: number, scale: number) => strin
|
|
|
298
302
|
declare const getMatrixTransformStyles: (x: number, y: number, scale: number) => string;
|
|
299
303
|
declare const getCenterPosition: (scale: number, wrapperComponent: HTMLDivElement, contentComponent: HTMLDivElement) => StateType;
|
|
300
304
|
|
|
301
|
-
export { AnimationType, BoundsType, Context, KeepScale, LibrarySetup, MiniMap, MiniMapProps, PositionType, ReactZoomPanPinchComponentHelpers, ReactZoomPanPinchContentRef, ReactZoomPanPinchContext, ReactZoomPanPinchContextState, ReactZoomPanPinchHandlers, ReactZoomPanPinchProps, ReactZoomPanPinchRef, ReactZoomPanPinchRefProps, ReactZoomPanPinchState, SizeType, StateType, TransformComponent, TransformWrapper, VelocityType, getCenterPosition, getMatrixTransformStyles, getTransformStyles, useControls, useTransformComponent, useTransformContext, useTransformEffect, useTransformInit };
|
|
305
|
+
export { AnimationType, BoundsType, Context, KeepScale, LibrarySetup, MiniMap, MiniMapProps, PositionType, ReactZoomPanPinchBaseClasses, ReactZoomPanPinchComponentHelpers, ReactZoomPanPinchContentRef, ReactZoomPanPinchContext, ReactZoomPanPinchContextState, ReactZoomPanPinchHandlers, ReactZoomPanPinchProps, ReactZoomPanPinchRef, ReactZoomPanPinchRefProps, ReactZoomPanPinchState, SizeType, StateType, TransformComponent, TransformWrapper, VelocityType, getCenterPosition, getMatrixTransformStyles, getTransformStyles, useControls, useTransformComponent, useTransformContext, useTransformEffect, useTransformInit };
|
package/dist/index.esm.js
CHANGED
|
@@ -717,6 +717,10 @@ var initialSetup = {
|
|
|
717
717
|
equalToMove: true,
|
|
718
718
|
},
|
|
719
719
|
};
|
|
720
|
+
var baseClasses = {
|
|
721
|
+
wrapperClass: "react-transform-wrapper",
|
|
722
|
+
contentClass: "react-transform-component",
|
|
723
|
+
};
|
|
720
724
|
|
|
721
725
|
var createState = function (props) {
|
|
722
726
|
var _a, _b, _c, _d;
|
|
@@ -948,9 +952,10 @@ function makePassiveEventOption() {
|
|
|
948
952
|
}
|
|
949
953
|
}
|
|
950
954
|
|
|
955
|
+
var matchPrefix = ".".concat(baseClasses.wrapperClass);
|
|
951
956
|
var isExcludedNode = function (node, excluded) {
|
|
952
957
|
return excluded.some(function (exclude) {
|
|
953
|
-
return node.matches("".concat(exclude, ", .").concat(exclude, ", ").concat(exclude, " *, .").concat(exclude, " *"));
|
|
958
|
+
return node.matches("".concat(matchPrefix, " ").concat(exclude, ", ").concat(matchPrefix, " .").concat(exclude, ", ").concat(matchPrefix, " ").concat(exclude, " *, ").concat(matchPrefix, " .").concat(exclude, " *"));
|
|
954
959
|
});
|
|
955
960
|
};
|
|
956
961
|
var cancelTimeout = function (timeout) {
|
|
@@ -1842,6 +1847,19 @@ var MiniMap = function (_a) {
|
|
|
1842
1847
|
var mainRef = useRef(null);
|
|
1843
1848
|
var wrapperRef = useRef(null);
|
|
1844
1849
|
var previewRef = useRef(null);
|
|
1850
|
+
var getViewportSize = useCallback(function () {
|
|
1851
|
+
if (instance.wrapperComponent) {
|
|
1852
|
+
var rect = instance.wrapperComponent.getBoundingClientRect();
|
|
1853
|
+
return {
|
|
1854
|
+
width: rect.width,
|
|
1855
|
+
height: rect.height
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
return {
|
|
1859
|
+
width: 0,
|
|
1860
|
+
height: 0
|
|
1861
|
+
};
|
|
1862
|
+
}, [instance.wrapperComponent]);
|
|
1845
1863
|
var getContentSize = useCallback(function () {
|
|
1846
1864
|
if (instance.contentComponent) {
|
|
1847
1865
|
var rect = instance.contentComponent.getBoundingClientRect();
|
|
@@ -1900,7 +1918,7 @@ var MiniMap = function (_a) {
|
|
|
1900
1918
|
mainRef.current.style.height = "".concat(miniSize.height, "px");
|
|
1901
1919
|
}
|
|
1902
1920
|
if (previewRef.current) {
|
|
1903
|
-
var size =
|
|
1921
|
+
var size = getViewportSize();
|
|
1904
1922
|
var scale = computeMiniMapScale();
|
|
1905
1923
|
var previewScale = scale * (1 / instance.transformState.scale);
|
|
1906
1924
|
var transform = instance.handleTransformStyles(-instance.transformState.positionX * previewScale, -instance.transformState.positionY * previewScale, 1);
|
|
@@ -1992,8 +2010,8 @@ var TransformComponent = function (_a) {
|
|
|
1992
2010
|
cleanupWindowEvents === null || cleanupWindowEvents === void 0 ? void 0 : cleanupWindowEvents();
|
|
1993
2011
|
};
|
|
1994
2012
|
}, []);
|
|
1995
|
-
return (React.createElement("div", __assign({}, wrapperProps, { ref: wrapperRef, className: "
|
|
1996
|
-
React.createElement("div", __assign({}, contentProps, { ref: contentRef, className: "
|
|
2013
|
+
return (React.createElement("div", __assign({}, wrapperProps, { ref: wrapperRef, className: "".concat(baseClasses.wrapperClass, " ").concat(styles.wrapper, " ").concat(wrapperClass), style: wrapperStyle }),
|
|
2014
|
+
React.createElement("div", __assign({}, contentProps, { ref: contentRef, className: "".concat(baseClasses.contentClass, " ").concat(styles.content, " ").concat(contentClass), style: contentStyle }), children)));
|
|
1997
2015
|
};
|
|
1998
2016
|
|
|
1999
2017
|
var useTransformContext = function () {
|
|
@@ -2045,7 +2063,20 @@ var useTransformEffect = function (callback) {
|
|
|
2045
2063
|
|
|
2046
2064
|
function useTransformComponent(callback) {
|
|
2047
2065
|
var libraryContext = useTransformContext();
|
|
2048
|
-
|
|
2066
|
+
var _a = useState(callback(getState(libraryContext))), transformRender = _a[0], setTransformRender = _a[1];
|
|
2067
|
+
useEffect(function () {
|
|
2068
|
+
var mounted = true;
|
|
2069
|
+
var unmount = libraryContext.onChange(function (ref) {
|
|
2070
|
+
if (mounted) {
|
|
2071
|
+
setTransformRender(callback(getState(ref.instance)));
|
|
2072
|
+
}
|
|
2073
|
+
});
|
|
2074
|
+
return function () {
|
|
2075
|
+
unmount();
|
|
2076
|
+
mounted = false;
|
|
2077
|
+
};
|
|
2078
|
+
}, [callback, libraryContext]);
|
|
2079
|
+
return transformRender;
|
|
2049
2080
|
}
|
|
2050
2081
|
|
|
2051
2082
|
export { Context, KeepScale, MiniMap, TransformComponent, TransformWrapper, getCenterPosition, getMatrixTransformStyles, getTransformStyles, useControls, useTransformComponent, useTransformContext, useTransformEffect, useTransformInit };
|