react-zoom-pan-pinch 3.4.0 → 3.4.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.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
@@ -1262,6 +1262,12 @@ var handleDoubleClickResetMode = function (contextInstance, event) {
1262
1262
  });
1263
1263
  handleDoubleClickStop(contextInstance, event);
1264
1264
  };
1265
+ function getDoubleClickScale(mode, scale) {
1266
+ if (mode === "toggle") {
1267
+ return scale === 1 ? 1 : -1;
1268
+ }
1269
+ return mode === "zoomOut" ? -1 : 1;
1270
+ }
1265
1271
  function handleDoubleClick(contextInstance, event) {
1266
1272
  var setup = contextInstance.setup, doubleClickStopEventTimer = contextInstance.doubleClickStopEventTimer, transformState = contextInstance.transformState, contentComponent = contextInstance.contentComponent;
1267
1273
  var scale = transformState.scale;
@@ -1276,7 +1282,7 @@ function handleDoubleClick(contextInstance, event) {
1276
1282
  }
1277
1283
  if (!contentComponent)
1278
1284
  return console.error("No ContentComponent found");
1279
- var delta = mode === "zoomOut" ? -1 : 1;
1285
+ var delta = getDoubleClickScale(mode, contextInstance.transformState.scale);
1280
1286
  var newScale = handleCalculateButtonZoom(contextInstance, delta, step);
1281
1287
  // stop execution when scale didn't change
1282
1288
  if (scale === newScale)
@@ -1351,6 +1357,7 @@ var ZoomPanPinch = /** @class */ (function () {
1351
1357
  _this.cleanupWindowEvents();
1352
1358
  };
1353
1359
  this.update = function (newProps) {
1360
+ _this.props = newProps;
1354
1361
  handleCalculateBounds(_this, _this.transformState.scale);
1355
1362
  _this.setup = createSetup(newProps);
1356
1363
  };