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

Commit 22341e6

Browse files
authored
Merge pull request #239 from mei-mu/master
support image reset
2 parents 8080994 + 97aaa36 commit 22341e6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/image-viewer.component.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from 'react';
2+
23
import {
34
Animated,
45
CameraRoll,
@@ -45,6 +46,8 @@ export default class ImageViewer extends React.Component<Props, State> {
4546

4647
private handleLongPressWithIndex = new Map<number, any>();
4748

49+
private imageRefs: any[] = [];
50+
4851
public componentWillMount() {
4952
this.init(this.props);
5053
}
@@ -110,7 +113,12 @@ export default class ImageViewer extends React.Component<Props, State> {
110113
}
111114
);
112115
}
113-
116+
/**
117+
* reset Image scale and position
118+
*/
119+
public resetImageByIndex = (index: number) => {
120+
this.imageRefs[index] && this.imageRefs[index].reset();
121+
};
114122
/**
115123
* 调到当前看图位置
116124
*/
@@ -499,6 +507,7 @@ export default class ImageViewer extends React.Component<Props, State> {
499507
return (
500508
<ImageZoom
501509
key={index}
510+
ref={el => (this.imageRefs[index] = el)}
502511
cropWidth={this.width}
503512
cropHeight={this.height}
504513
maxOverflow={this.props.maxOverflow}

0 commit comments

Comments
 (0)