Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasvo committed Dec 4, 2024
1 parent 821f9fa commit 1331805
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 24 deletions.
14 changes: 8 additions & 6 deletions lib/commonjs/ReactNativeZoomableView.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/commonjs/ReactNativeZoomableView.js.map

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions lib/module/ReactNativeZoomableView.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/module/ReactNativeZoomableView.js.map

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions lib/typescript/ReactNativeZoomableView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,15 @@ declare class ReactNativeZoomableView extends Component<ReactNativeZoomableViewP
*/
_getNextZoomStep(): number | undefined;
/**
* Zooms to a specific level. A specific location to zoom to can be specified.
* The location provided is relative to the zoom subject where center is 0,0.
* Zooms to a specific level. A "zoom center" can be provided, which specifies
* the point that will remain in the same position on the screen after the zoom.
* The coordinates of the zoom center is relative to the zoom subject.
* { x: 0, y: 0 } is the very center of the zoom subject.
*
* @param newZoomLevel
* @param coords relative coords compared to the zoom subject. Default to the center.
* @param zoomCenter relative coords compared to the zoom subject. Default to the center.
*/
zoomTo(newZoomLevel: number, coords?: {
zoomTo(newZoomLevel: number, zoomCenter?: {
x: number;
y: number;
}): true | undefined;
Expand Down
14 changes: 8 additions & 6 deletions src/ReactNativeZoomableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1075,13 +1075,15 @@ class ReactNativeZoomableView extends Component<
}

/**
* Zooms to a specific level. A specific location to zoom to can be specified.
* The location provided is relative to the zoom subject where center is 0,0.
* Zooms to a specific level. A "zoom center" can be provided, which specifies
* the point that will remain in the same position on the screen after the zoom.
* The coordinates of the zoom center is relative to the zoom subject.
* { x: 0, y: 0 } is the very center of the zoom subject.
*
* @param newZoomLevel
* @param coords relative coords compared to the zoom subject. Default to the center.
* @param zoomCenter relative coords compared to the zoom subject. Default to the center.
*/
zoomTo(newZoomLevel: number, coords = { x: 0, y: 0 }) {
zoomTo(newZoomLevel: number, zoomCenter = { x: 0, y: 0 }) {
if (!this.props.zoomEnabled) return;
if (this.props.maxZoom && newZoomLevel > this.props.maxZoom) return;
if (this.props.minZoom && newZoomLevel < this.props.minZoom) return;
Expand All @@ -1102,14 +1104,14 @@ class ReactNativeZoomableView extends Component<
this.state.originalWidth,
prevScale,
newScale,
coords.x
zoomCenter.x
),
y: calcNewScaledOffsetForZoomCentering(
this.offsetY,
this.state.originalHeight,
prevScale,
newScale,
coords.y
zoomCenter.y
),
});
prevScale = newScale;
Expand Down

0 comments on commit 1331805

Please sign in to comment.