Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/bounds/bounds.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export const getBounds = (
): BoundsType => {
const scaleWidthFactor =
wrapperWidth > newContentWidth
? diffWidth * (centerZoomedOut ? 1 : 0.5)
? diffWidth * (centerZoomedOut ? 0.5 : 1)
: 0;
const scaleHeightFactor =
wrapperHeight > newContentHeight
? diffHeight * (centerZoomedOut ? 1 : 0.5)
? diffHeight * (centerZoomedOut ? 0.5 : 1)
: 0;

const minPositionX = wrapperWidth - newContentWidth - scaleWidthFactor;
Expand Down
17 changes: 14 additions & 3 deletions src/core/pinch/pinch.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ export const handlePinchZoom = (
const { contentComponent, pinchStartDistance, wrapperComponent } =
contextInstance;
const { scale } = contextInstance.transformState;
const { limitToBounds, centerZoomedOut, zoomAnimation, alignmentAnimation } =
contextInstance.setup;
const {
alignmentAnimation,
centerZoomedOut,
disablePadding,
limitToBounds,
zoomAnimation,
} = contextInstance.setup;
const { disabled, size } = zoomAnimation;

// if one finger starts from outside of wrapper
Expand All @@ -82,7 +87,13 @@ export const handlePinchZoom = (

const bounds = handleCalculateBounds(contextInstance, newScale);

const isPaddingDisabled = disabled || size === 0 || centerZoomedOut;
const isPaddingDisabled =
disabled ||
size === 0 ||
disablePadding ||
centerZoomedOut ||
bounds.maxPositionX === 0 ||
bounds.maxPositionY === 0;
const isLimitedToBounds = limitToBounds && isPaddingDisabled;

const { x, y } = handleCalculateZoomPositions(
Expand Down
13 changes: 9 additions & 4 deletions src/core/wheel/wheel.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ export const handleWheelZoom = (
const { contentComponent, setup, transformState } = contextInstance;
const { scale } = transformState;
const {
limitToBounds,
centerZoomedOut,
zoomAnimation,
wheel,
disablePadding,
limitToBounds,
smooth,
wheel,
zoomAnimation,
} = setup;
const { size, disabled } = zoomAnimation;
const { step, smoothStep } = wheel;
Expand Down Expand Up @@ -73,7 +73,12 @@ export const handleWheelZoom = (
const mousePosition = getMousePosition(event, contentComponent, scale);

const isPaddingDisabled =
disabled || size === 0 || centerZoomedOut || disablePadding;
disabled ||
size === 0 ||
disablePadding ||
centerZoomedOut ||
bounds.maxPositionX === 0 ||
bounds.maxPositionY === 0;
const isLimitedToBounds = limitToBounds && isPaddingDisabled;

const { x, y } = handleCalculateZoomPositions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import exampleImg from "../../assets/medium-image.jpg";

export const Template = (args) => (
<TransformWrapper
centerZoomedOut
{...normalizeArgs(args)}
initialScale={0.4}
minScale={0.2}
Expand Down