Skip to content
This repository was archived by the owner on Sep 28, 2021. It is now read-only.

Commit e7e91ea

Browse files
committed
Added onMove prop to ImageZoom
1 parent 0f75b42 commit e7e91ea

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ export default class App extends React.Component {
8686
| loadingRender | function<br><br>`() => React.ReactElement<any>` | no | placeholder for loading | `() => null` |
8787
| onSaveToCamera | function<br><br>`(index?: number => void` | no | The callback for save to camera | `() => {}` |
8888
| onChange | function<br><br>`(index?: number => void` | no | When the image changed | `() => {}` |
89+
| onMove | ( position: [IOnMove](https://github.com/ascoders/react-native-image-zoom/blob/master/src/image-zoom/image-zoom.type.ts) )=>void | reports movement position data (helpful to build overlays) | ()=> {} |
90+
8991
| saveToLocalByLongPress | boolean | no | Enable save to camera when long press | `true` |
9092
| onClick | function<br><br>`(onCancel?: function) => void` | no | Onclick | `(onCancel) => {onCancel()}` |
9193
| onDoubleClick | function<br><br>`(onCancel?: function) => void` | no | OnDoubleClick | `(onCancel) => {onCancel()}` |

demo/App.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export default class Main extends Component {
5353
onSwipeDown={() => {
5454
console.log('onSwipeDown');
5555
}}
56+
onMove={data => console.log(data)}
5657
enableSwipeDown={true}
5758
/>
5859
</Modal>

src/image-viewer.component.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ export default class ImageViewer extends React.Component<Props, State> {
469469
maxOverflow={this.props.maxOverflow}
470470
horizontalOuterRangeOffset={this.handleHorizontalOuterRangeOffset}
471471
responderRelease={this.handleResponderRelease}
472+
onMove={this.props.onMove}
472473
onLongPress={this.handleLongPressWithIndex.get(index)}
473474
onClick={this.handleClick}
474475
onDoubleClick={this.handleDoubleClick}
@@ -537,6 +538,7 @@ export default class ImageViewer extends React.Component<Props, State> {
537538
maxOverflow={this.props.maxOverflow}
538539
horizontalOuterRangeOffset={this.handleHorizontalOuterRangeOffset}
539540
responderRelease={this.handleResponderRelease}
541+
onMove={this.props.onMove}
540542
onLongPress={this.handleLongPressWithIndex.get(index)}
541543
onClick={this.handleClick}
542544
onDoubleClick={this.handleDoubleClick}

src/image-viewer.type.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ import * as React from 'react';
22
import { Image, ImageURISource, Text, View, ViewStyle } from 'react-native';
33
import { simpleStyle } from './image-viewer.style';
44

5+
interface IOnMove {
6+
type: string;
7+
positionX: number;
8+
positionY: number;
9+
scale: number;
10+
zoomCurrentDistance: number;
11+
}
12+
513
export class Props {
614
/**
715
* 是否显示
@@ -112,6 +120,10 @@ export class Props {
112120
//
113121
};
114122

123+
public onMove?: (position?: IOnMove) => void = () => {
124+
//
125+
};
126+
115127
/**
116128
* 自定义头部
117129
*/

0 commit comments

Comments
 (0)