react-zoom-pan-pinch 3.5.1 → 3.6.1
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 +23 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.esm.js +23 -8
- 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) {
|
|
@@ -1590,10 +1595,7 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1590
1595
|
if (!isAllowed)
|
|
1591
1596
|
return;
|
|
1592
1597
|
var isDoubleTap = _this.lastTouch && +new Date() - _this.lastTouch < 200;
|
|
1593
|
-
if (isDoubleTap
|
|
1594
|
-
_this.onDoubleClick(event);
|
|
1595
|
-
}
|
|
1596
|
-
else {
|
|
1598
|
+
if (!isDoubleTap) {
|
|
1597
1599
|
_this.lastTouch = +new Date();
|
|
1598
1600
|
handleCancelAnimation(_this);
|
|
1599
1601
|
var touches = event.touches;
|
|
@@ -1842,6 +1844,19 @@ var MiniMap = function (_a) {
|
|
|
1842
1844
|
var mainRef = useRef(null);
|
|
1843
1845
|
var wrapperRef = useRef(null);
|
|
1844
1846
|
var previewRef = useRef(null);
|
|
1847
|
+
var getViewportSize = useCallback(function () {
|
|
1848
|
+
if (instance.wrapperComponent) {
|
|
1849
|
+
var rect = instance.wrapperComponent.getBoundingClientRect();
|
|
1850
|
+
return {
|
|
1851
|
+
width: rect.width,
|
|
1852
|
+
height: rect.height
|
|
1853
|
+
};
|
|
1854
|
+
}
|
|
1855
|
+
return {
|
|
1856
|
+
width: 0,
|
|
1857
|
+
height: 0
|
|
1858
|
+
};
|
|
1859
|
+
}, [instance.wrapperComponent]);
|
|
1845
1860
|
var getContentSize = useCallback(function () {
|
|
1846
1861
|
if (instance.contentComponent) {
|
|
1847
1862
|
var rect = instance.contentComponent.getBoundingClientRect();
|
|
@@ -1900,7 +1915,7 @@ var MiniMap = function (_a) {
|
|
|
1900
1915
|
mainRef.current.style.height = "".concat(miniSize.height, "px");
|
|
1901
1916
|
}
|
|
1902
1917
|
if (previewRef.current) {
|
|
1903
|
-
var size =
|
|
1918
|
+
var size = getViewportSize();
|
|
1904
1919
|
var scale = computeMiniMapScale();
|
|
1905
1920
|
var previewScale = scale * (1 / instance.transformState.scale);
|
|
1906
1921
|
var transform = instance.handleTransformStyles(-instance.transformState.positionX * previewScale, -instance.transformState.positionY * previewScale, 1);
|
|
@@ -1992,8 +2007,8 @@ var TransformComponent = function (_a) {
|
|
|
1992
2007
|
cleanupWindowEvents === null || cleanupWindowEvents === void 0 ? void 0 : cleanupWindowEvents();
|
|
1993
2008
|
};
|
|
1994
2009
|
}, []);
|
|
1995
|
-
return (React.createElement("div", __assign({}, wrapperProps, { ref: wrapperRef, className: "
|
|
1996
|
-
React.createElement("div", __assign({}, contentProps, { ref: contentRef, className: "
|
|
2010
|
+
return (React.createElement("div", __assign({}, wrapperProps, { ref: wrapperRef, className: "".concat(baseClasses.wrapperClass, " ").concat(styles.wrapper, " ").concat(wrapperClass), style: wrapperStyle }),
|
|
2011
|
+
React.createElement("div", __assign({}, contentProps, { ref: contentRef, className: "".concat(baseClasses.contentClass, " ").concat(styles.content, " ").concat(contentClass), style: contentStyle }), children)));
|
|
1997
2012
|
};
|
|
1998
2013
|
|
|
1999
2014
|
var useTransformContext = function () {
|