react-zoom-pan-pinch 3.6.0 → 3.7.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 +50 -35
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +50 -35
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ declare class ZoomPanPinch {
|
|
|
77
77
|
initializeWindowEvents: () => void;
|
|
78
78
|
cleanupWindowEvents: () => void;
|
|
79
79
|
handleInitializeWrapperEvents: (wrapper: HTMLDivElement) => void;
|
|
80
|
-
handleInitialize: (contentComponent: HTMLDivElement) => void;
|
|
80
|
+
handleInitialize: (wrapper: HTMLDivElement, contentComponent: HTMLDivElement) => void;
|
|
81
81
|
onWheelZoom: (event: WheelEvent) => void;
|
|
82
82
|
onWheelPanning: (event: WheelEvent) => void;
|
|
83
83
|
onPanningStart: (event: MouseEvent) => void;
|
package/dist/index.esm.js
CHANGED
|
@@ -520,7 +520,7 @@ function handlePanningStart(contextInstance, event) {
|
|
|
520
520
|
handlePanningSetup(contextInstance, event);
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
|
-
function handleAlignToBounds(contextInstance) {
|
|
523
|
+
function handleAlignToBounds(contextInstance, customAnimationTime) {
|
|
524
524
|
var scale = contextInstance.transformState.scale;
|
|
525
525
|
var _a = contextInstance.setup, minScale = _a.minScale, alignmentAnimation = _a.alignmentAnimation;
|
|
526
526
|
var disabled = alignmentAnimation.disabled, sizeX = alignmentAnimation.sizeX, sizeY = alignmentAnimation.sizeY, animationTime = alignmentAnimation.animationTime, animationType = alignmentAnimation.animationType;
|
|
@@ -529,7 +529,7 @@ function handleAlignToBounds(contextInstance) {
|
|
|
529
529
|
return;
|
|
530
530
|
var targetState = handlePanToBounds(contextInstance);
|
|
531
531
|
if (targetState) {
|
|
532
|
-
animate(contextInstance, targetState, animationTime, animationType);
|
|
532
|
+
animate(contextInstance, targetState, customAnimationTime !== null && customAnimationTime !== void 0 ? customAnimationTime : animationTime, animationType);
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
535
|
function handlePanning(contextInstance, clientX, clientY) {
|
|
@@ -640,7 +640,12 @@ function __spreadArray(to, from, pack) {
|
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
642
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
643
|
-
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
646
|
+
var e = new Error(message);
|
|
647
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
648
|
+
};
|
|
644
649
|
|
|
645
650
|
var initialState = {
|
|
646
651
|
previousScale: 1,
|
|
@@ -1427,32 +1432,43 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1427
1432
|
wrapper.addEventListener("touchmove", _this.onTouchPanning, passive);
|
|
1428
1433
|
wrapper.addEventListener("touchend", _this.onTouchPanningStop, passive);
|
|
1429
1434
|
};
|
|
1430
|
-
this.handleInitialize = function (contentComponent) {
|
|
1435
|
+
this.handleInitialize = function (wrapper, contentComponent) {
|
|
1436
|
+
var isCentered = false;
|
|
1431
1437
|
var centerOnInit = _this.setup.centerOnInit;
|
|
1438
|
+
var hasTarget = function (entries, target) {
|
|
1439
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
1440
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
1441
|
+
var entry = entries_1[_i];
|
|
1442
|
+
if (entry.target === target) {
|
|
1443
|
+
return true;
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
return false;
|
|
1447
|
+
};
|
|
1432
1448
|
_this.applyTransformation();
|
|
1433
|
-
_this.onInitCallbacks.forEach(function (callback) {
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
(_a = _this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
1449
|
+
_this.onInitCallbacks.forEach(function (callback) {
|
|
1450
|
+
callback(getContext(_this));
|
|
1451
|
+
});
|
|
1452
|
+
_this.observer = new ResizeObserver(function (entries) {
|
|
1453
|
+
if (hasTarget(entries, wrapper) || hasTarget(entries, contentComponent)) {
|
|
1454
|
+
if (centerOnInit && !isCentered) {
|
|
1455
|
+
var currentWidth = contentComponent.offsetWidth;
|
|
1456
|
+
var currentHeight = contentComponent.offsetHeight;
|
|
1457
|
+
if (currentWidth > 0 || currentHeight > 0) {
|
|
1458
|
+
isCentered = true;
|
|
1459
|
+
_this.setCenter();
|
|
1460
|
+
}
|
|
1446
1461
|
}
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1462
|
+
else {
|
|
1463
|
+
handleCancelAnimation(_this);
|
|
1464
|
+
handleCalculateBounds(_this, _this.transformState.scale);
|
|
1465
|
+
handleAlignToBounds(_this, 0);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
});
|
|
1469
|
+
// Start observing the target node for configured mutations
|
|
1470
|
+
_this.observer.observe(wrapper);
|
|
1471
|
+
_this.observer.observe(contentComponent);
|
|
1456
1472
|
};
|
|
1457
1473
|
/// ///////
|
|
1458
1474
|
// Zoom
|
|
@@ -1594,11 +1610,10 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1594
1610
|
var isAllowed = isPanningStartAllowed(_this, event);
|
|
1595
1611
|
if (!isAllowed)
|
|
1596
1612
|
return;
|
|
1597
|
-
var isDoubleTap = _this.lastTouch &&
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
else {
|
|
1613
|
+
var isDoubleTap = _this.lastTouch &&
|
|
1614
|
+
+new Date() - _this.lastTouch < 200 &&
|
|
1615
|
+
event.touches.length === 1;
|
|
1616
|
+
if (!isDoubleTap) {
|
|
1602
1617
|
_this.lastTouch = +new Date();
|
|
1603
1618
|
handleCancelAnimation(_this);
|
|
1604
1619
|
var touches = event.touches;
|
|
@@ -1739,7 +1754,7 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1739
1754
|
_this.contentComponent = contentComponent;
|
|
1740
1755
|
handleCalculateBounds(_this, _this.transformState.scale);
|
|
1741
1756
|
_this.handleInitializeWrapperEvents(wrapperComponent);
|
|
1742
|
-
_this.handleInitialize(contentComponent);
|
|
1757
|
+
_this.handleInitialize(wrapperComponent, contentComponent);
|
|
1743
1758
|
_this.initializeWindowEvents();
|
|
1744
1759
|
_this.isInitialized = true;
|
|
1745
1760
|
var ctx = getContext(_this);
|
|
@@ -1852,12 +1867,12 @@ var MiniMap = function (_a) {
|
|
|
1852
1867
|
var rect = instance.wrapperComponent.getBoundingClientRect();
|
|
1853
1868
|
return {
|
|
1854
1869
|
width: rect.width,
|
|
1855
|
-
height: rect.height
|
|
1870
|
+
height: rect.height,
|
|
1856
1871
|
};
|
|
1857
1872
|
}
|
|
1858
1873
|
return {
|
|
1859
1874
|
width: 0,
|
|
1860
|
-
height: 0
|
|
1875
|
+
height: 0,
|
|
1861
1876
|
};
|
|
1862
1877
|
}, [instance.wrapperComponent]);
|
|
1863
1878
|
var getContentSize = useCallback(function () {
|
|
@@ -1990,7 +2005,7 @@ function styleInject(css, ref) {
|
|
|
1990
2005
|
}
|
|
1991
2006
|
}
|
|
1992
2007
|
|
|
1993
|
-
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 -webkit-user-select: none; /* Safari */\n -khtml-user-select: none; /* Konqueror HTML */\n -moz-user-select: none; /* Firefox */\n -ms-user-select: none; /* Internet Explorer/Edge */\n user-select: none;\n margin: 0;\n padding: 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";
|
|
2008
|
+
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 -webkit-user-select: none; /* Safari */\n -khtml-user-select: none; /* Konqueror HTML */\n -moz-user-select: none; /* Firefox */\n -ms-user-select: none; /* Internet Explorer/Edge */\n user-select: none;\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";
|
|
1994
2009
|
var styles = {"wrapper":"transform-component-module_wrapper__SPB86","content":"transform-component-module_content__FBWxo"};
|
|
1995
2010
|
styleInject(css_248z);
|
|
1996
2011
|
|