react-zoom-pan-pinch 3.4.0 → 3.4.2

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.d.ts CHANGED
@@ -182,7 +182,7 @@ type ReactZoomPanPinchProps = {
182
182
  doubleClick?: {
183
183
  disabled?: boolean;
184
184
  step?: number;
185
- mode?: "zoomIn" | "zoomOut" | "reset";
185
+ mode?: "zoomIn" | "zoomOut" | "reset" | "toggle";
186
186
  animationTime?: number;
187
187
  animationType?: keyof typeof animations;
188
188
  excluded?: string[];
package/dist/index.esm.js CHANGED
@@ -949,16 +949,9 @@ function makePassiveEventOption() {
949
949
  }
950
950
 
951
951
  var isExcludedNode = function (node, excluded) {
952
- var targetTagName = node.tagName.toUpperCase();
953
- var isExcludedTag = excluded.find(function (tag) { return tag.toUpperCase() === targetTagName; });
954
- if (isExcludedTag)
955
- return true;
956
- var isExcludedClassName = excluded.find(function (className) {
957
- return node.classList.contains(className);
952
+ return excluded.some(function (exclude) {
953
+ return node.matches("".concat(exclude, ", .").concat(exclude, ", ").concat(exclude, " *, .").concat(exclude, " *"));
958
954
  });
959
- if (isExcludedClassName)
960
- return true;
961
- return false;
962
955
  };
963
956
  var cancelTimeout = function (timeout) {
964
957
  if (timeout) {
@@ -1262,6 +1255,12 @@ var handleDoubleClickResetMode = function (contextInstance, event) {
1262
1255
  });
1263
1256
  handleDoubleClickStop(contextInstance, event);
1264
1257
  };
1258
+ function getDoubleClickScale(mode, scale) {
1259
+ if (mode === "toggle") {
1260
+ return scale === 1 ? 1 : -1;
1261
+ }
1262
+ return mode === "zoomOut" ? -1 : 1;
1263
+ }
1265
1264
  function handleDoubleClick(contextInstance, event) {
1266
1265
  var setup = contextInstance.setup, doubleClickStopEventTimer = contextInstance.doubleClickStopEventTimer, transformState = contextInstance.transformState, contentComponent = contextInstance.contentComponent;
1267
1266
  var scale = transformState.scale;
@@ -1276,7 +1275,7 @@ function handleDoubleClick(contextInstance, event) {
1276
1275
  }
1277
1276
  if (!contentComponent)
1278
1277
  return console.error("No ContentComponent found");
1279
- var delta = mode === "zoomOut" ? -1 : 1;
1278
+ var delta = getDoubleClickScale(mode, contextInstance.transformState.scale);
1280
1279
  var newScale = handleCalculateButtonZoom(contextInstance, delta, step);
1281
1280
  // stop execution when scale didn't change
1282
1281
  if (scale === newScale)
@@ -1351,6 +1350,7 @@ var ZoomPanPinch = /** @class */ (function () {
1351
1350
  _this.cleanupWindowEvents();
1352
1351
  };
1353
1352
  this.update = function (newProps) {
1353
+ _this.props = newProps;
1354
1354
  handleCalculateBounds(_this, _this.transformState.scale);
1355
1355
  _this.setup = createSetup(newProps);
1356
1356
  };