react-zoom-pan-pinch 3.6.1 → 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 +49 -31
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +49 -31
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -2
package/dist/index.cjs.js
CHANGED
|
@@ -528,7 +528,7 @@ function handlePanningStart(contextInstance, event) {
|
|
|
528
528
|
handlePanningSetup(contextInstance, event);
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
|
-
function handleAlignToBounds(contextInstance) {
|
|
531
|
+
function handleAlignToBounds(contextInstance, customAnimationTime) {
|
|
532
532
|
var scale = contextInstance.transformState.scale;
|
|
533
533
|
var _a = contextInstance.setup, minScale = _a.minScale, alignmentAnimation = _a.alignmentAnimation;
|
|
534
534
|
var disabled = alignmentAnimation.disabled, sizeX = alignmentAnimation.sizeX, sizeY = alignmentAnimation.sizeY, animationTime = alignmentAnimation.animationTime, animationType = alignmentAnimation.animationType;
|
|
@@ -537,7 +537,7 @@ function handleAlignToBounds(contextInstance) {
|
|
|
537
537
|
return;
|
|
538
538
|
var targetState = handlePanToBounds(contextInstance);
|
|
539
539
|
if (targetState) {
|
|
540
|
-
animate(contextInstance, targetState, animationTime, animationType);
|
|
540
|
+
animate(contextInstance, targetState, customAnimationTime !== null && customAnimationTime !== void 0 ? customAnimationTime : animationTime, animationType);
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
function handlePanning(contextInstance, clientX, clientY) {
|
|
@@ -648,7 +648,12 @@ function __spreadArray(to, from, pack) {
|
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
650
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
651
|
-
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
654
|
+
var e = new Error(message);
|
|
655
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
656
|
+
};
|
|
652
657
|
|
|
653
658
|
var initialState = {
|
|
654
659
|
previousScale: 1,
|
|
@@ -1435,32 +1440,43 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1435
1440
|
wrapper.addEventListener("touchmove", _this.onTouchPanning, passive);
|
|
1436
1441
|
wrapper.addEventListener("touchend", _this.onTouchPanningStop, passive);
|
|
1437
1442
|
};
|
|
1438
|
-
this.handleInitialize = function (contentComponent) {
|
|
1443
|
+
this.handleInitialize = function (wrapper, contentComponent) {
|
|
1444
|
+
var isCentered = false;
|
|
1439
1445
|
var centerOnInit = _this.setup.centerOnInit;
|
|
1446
|
+
var hasTarget = function (entries, target) {
|
|
1447
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
1448
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
1449
|
+
var entry = entries_1[_i];
|
|
1450
|
+
if (entry.target === target) {
|
|
1451
|
+
return true;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
return false;
|
|
1455
|
+
};
|
|
1440
1456
|
_this.applyTransformation();
|
|
1441
|
-
_this.onInitCallbacks.forEach(function (callback) {
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
(_a = _this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
1457
|
+
_this.onInitCallbacks.forEach(function (callback) {
|
|
1458
|
+
callback(getContext(_this));
|
|
1459
|
+
});
|
|
1460
|
+
_this.observer = new ResizeObserver(function (entries) {
|
|
1461
|
+
if (hasTarget(entries, wrapper) || hasTarget(entries, contentComponent)) {
|
|
1462
|
+
if (centerOnInit && !isCentered) {
|
|
1463
|
+
var currentWidth = contentComponent.offsetWidth;
|
|
1464
|
+
var currentHeight = contentComponent.offsetHeight;
|
|
1465
|
+
if (currentWidth > 0 || currentHeight > 0) {
|
|
1466
|
+
isCentered = true;
|
|
1467
|
+
_this.setCenter();
|
|
1468
|
+
}
|
|
1454
1469
|
}
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1470
|
+
else {
|
|
1471
|
+
handleCancelAnimation(_this);
|
|
1472
|
+
handleCalculateBounds(_this, _this.transformState.scale);
|
|
1473
|
+
handleAlignToBounds(_this, 0);
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
});
|
|
1477
|
+
// Start observing the target node for configured mutations
|
|
1478
|
+
_this.observer.observe(wrapper);
|
|
1479
|
+
_this.observer.observe(contentComponent);
|
|
1464
1480
|
};
|
|
1465
1481
|
/// ///////
|
|
1466
1482
|
// Zoom
|
|
@@ -1602,7 +1618,9 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1602
1618
|
var isAllowed = isPanningStartAllowed(_this, event);
|
|
1603
1619
|
if (!isAllowed)
|
|
1604
1620
|
return;
|
|
1605
|
-
var isDoubleTap = _this.lastTouch &&
|
|
1621
|
+
var isDoubleTap = _this.lastTouch &&
|
|
1622
|
+
+new Date() - _this.lastTouch < 200 &&
|
|
1623
|
+
event.touches.length === 1;
|
|
1606
1624
|
if (!isDoubleTap) {
|
|
1607
1625
|
_this.lastTouch = +new Date();
|
|
1608
1626
|
handleCancelAnimation(_this);
|
|
@@ -1744,7 +1762,7 @@ var ZoomPanPinch = /** @class */ (function () {
|
|
|
1744
1762
|
_this.contentComponent = contentComponent;
|
|
1745
1763
|
handleCalculateBounds(_this, _this.transformState.scale);
|
|
1746
1764
|
_this.handleInitializeWrapperEvents(wrapperComponent);
|
|
1747
|
-
_this.handleInitialize(contentComponent);
|
|
1765
|
+
_this.handleInitialize(wrapperComponent, contentComponent);
|
|
1748
1766
|
_this.initializeWindowEvents();
|
|
1749
1767
|
_this.isInitialized = true;
|
|
1750
1768
|
var ctx = getContext(_this);
|
|
@@ -1857,12 +1875,12 @@ var MiniMap = function (_a) {
|
|
|
1857
1875
|
var rect = instance.wrapperComponent.getBoundingClientRect();
|
|
1858
1876
|
return {
|
|
1859
1877
|
width: rect.width,
|
|
1860
|
-
height: rect.height
|
|
1878
|
+
height: rect.height,
|
|
1861
1879
|
};
|
|
1862
1880
|
}
|
|
1863
1881
|
return {
|
|
1864
1882
|
width: 0,
|
|
1865
|
-
height: 0
|
|
1883
|
+
height: 0,
|
|
1866
1884
|
};
|
|
1867
1885
|
}, [instance.wrapperComponent]);
|
|
1868
1886
|
var getContentSize = React.useCallback(function () {
|
|
@@ -1995,7 +2013,7 @@ function styleInject(css, ref) {
|
|
|
1995
2013
|
}
|
|
1996
2014
|
}
|
|
1997
2015
|
|
|
1998
|
-
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";
|
|
2016
|
+
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";
|
|
1999
2017
|
var styles = {"wrapper":"transform-component-module_wrapper__SPB86","content":"transform-component-module_content__FBWxo"};
|
|
2000
2018
|
styleInject(css_248z);
|
|
2001
2019
|
|