Skip to content

Commit

Permalink
Got it
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottkember committed Feb 25, 2024
1 parent be1c037 commit 83bc773
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 45 deletions.
20 changes: 7 additions & 13 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: 8 additions & 14 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.

25 changes: 9 additions & 16 deletions src/ReactNativeZoomableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ import {
calcNewScaledOffsetForZoomCentering,
} from './helper';
import { applyPanBoundariesToOffset } from './helper/applyPanBoundariesToOffset';
import {
applyContainResizeMode,
viewportPositionToImagePosition,
} from './helper/coordinateConversion';
import { viewportPositionToImagePosition } from './helper/coordinateConversion';
import { StaticPin } from './components/StaticPin';
import { debounce } from 'lodash';
import {
Expand Down Expand Up @@ -906,21 +903,17 @@ class ReactNativeZoomableView extends Component<
};

moveStaticPinTo = (position: Vec2D) => {
const zoomableEvent = this._getZoomableViewEventObject();
const imageSize = {
height: this.props.contentHeight,
width: this.props.contentWidth,
};
const z = this._getZoomableViewEventObject();

const centreX = z.originalWidth / 2;
const centreY = z.originalHeight / 2;

const { scale } =
applyContainResizeMode(imageSize, {
width: zoomableEvent.originalWidth,
height: zoomableEvent.originalHeight,
}) || {};
const offsetX = this.props.staticPinPosition.x - centreX;
const offsetY = this.props.staticPinPosition.y - centreY;

const toValue = {
x: this.props.staticPinPosition.x - position.x * scale,
y: this.props.staticPinPosition.y - position.y * scale,
x: z.originalWidth / 2 - position.x + offsetX / z.zoomLevel,
y: z.originalHeight / 2 - position.y + offsetY / z.zoomLevel,
};

Animated.timing(this.panAnim, {
Expand Down

0 comments on commit 83bc773

Please sign in to comment.