Skip to content

Commit

Permalink
Merge pull request #127 from openspacelabs/louisb/zoom-to-coords
Browse files Browse the repository at this point in the history
Add zoom to coords
  • Loading branch information
louis-openspace authored Dec 3, 2024
2 parents 3d2003d + 7a06461 commit adf1a54
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 2 deletions.
13 changes: 13 additions & 0 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.

13 changes: 13 additions & 0 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.

4 changes: 4 additions & 0 deletions lib/typescript/ReactNativeZoomableView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ declare class ReactNativeZoomableView extends Component<ReactNativeZoomableViewP
* @return {bool}
*/
zoomTo(newZoomLevel: number): boolean;
/**
* Sets zoom relative to the zoomableview
*/
zoomToRelCoords(x: number, y: number, newZoomLevel: number): boolean;
/**
* Zooms in or out by a specified change level
* Use a positive number for `zoomLevelChange` to zoom in
Expand Down
15 changes: 15 additions & 0 deletions src/ReactNativeZoomableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,21 @@ class ReactNativeZoomableView extends Component<
return true;
}

/**
* Sets zoom relative to the zoomableview
*/
zoomToRelCoords(x: number, y: number, newZoomLevel: number) {
if (
// if we would go out of our min/max limits -> abort
(this.props.maxZoom && newZoomLevel > this.props.maxZoom) ||
(this.props.minZoom && newZoomLevel < this.props.minZoom)
)
return false;
// Just exposing _zoomToLocation
this._zoomToLocation(x, y, newZoomLevel);
return true;
}

/**
* Zooms in or out by a specified change level
* Use a positive number for `zoomLevelChange` to zoom in
Expand Down

0 comments on commit adf1a54

Please sign in to comment.