Skip to content

Commit

Permalink
Move static pin duration
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottkember committed Nov 2, 2024
1 parent 1068f42 commit a772a52
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 15 deletions.
22 changes: 17 additions & 5 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.

22 changes: 17 additions & 5 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.

2 changes: 1 addition & 1 deletion lib/typescript/ReactNativeZoomableView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ declare class ReactNativeZoomableView extends Component<ReactNativeZoomableViewP
* @private
*/
private _resolveAndHandleTap;
moveStaticPinTo: (position: Vec2D) => void;
moveStaticPinTo: (position: Vec2D, duration?: number) => void;
private _staticPinPosition;
private _updateStaticPin;
private _addTouch;
Expand Down
12 changes: 10 additions & 2 deletions src/ReactNativeZoomableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ class ReactNativeZoomableView extends Component<
}
};

moveStaticPinTo = (position: Vec2D) => {
moveStaticPinTo = (position: Vec2D, duration?: number) => {
const { originalWidth, originalHeight } = this.state;
const { staticPinPosition, contentWidth, contentHeight } = this.props;

Expand All @@ -965,7 +965,15 @@ class ReactNativeZoomableView extends Component<
this.offsetX = contentWidth / 2 - position.x + pinX / this.zoomLevel;
this.offsetY = contentHeight / 2 - position.y + pinY / this.zoomLevel;

this.panAnim.setValue({ x: this.offsetX, y: this.offsetY });
if (duration) {
Animated.timing(this.panAnim, {
toValue: { x: this.offsetX, y: this.offsetY },
useNativeDriver: true,
duration,
}).start();
} else {
this.panAnim.setValue({ x: this.offsetX, y: this.offsetY });
}
};

private _staticPinPosition = () => {
Expand Down

0 comments on commit a772a52

Please sign in to comment.