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

Add index argument into the renderImage callback. #483

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class App extends React.Component {
| renderHeader | function<br><br>`(currentIndex?: number) => React.ReactElement<any>` | no | Custom header | `() => null` |
| renderFooter | function<br><br>`(currentIndex?: number) => React.ReactElement<any>` | no | Custom footer | `() => null` |
| renderIndicator | function<br><br>`(currentIndex?: number, allSize?) => React.ReactElement<any>`: number | no | Custom indicator | `(currentIndex, allSize) => currentIndex + "/" + allSize` |
| renderImage | function<br><br>`(props: any) => React.ReactElement<any>` | no | Custom image component | `(props) => <Image {...props} />` |
| renderImage | function<br><br>`(props: any, index: number) => React.ReactElement<any>` | no | Custom image component | `(props) => <Image {...props} />` |
| renderArrowLeft | function<br><br>`() => React.ReactElement<any>` | no | Custom left arrow | `() => null` |
| renderArrowRight | function<br><br>`() => React.ReactElement<any>` | no | Custom right arrow | `() => null` |
| onSwipeDown | function<br><br>`() => void` | no | Callback for swipe down | `() => null` |
Expand Down
4 changes: 2 additions & 2 deletions src/image-viewer.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ export default class ImageViewer extends React.Component<Props, State> {
minScale={this.props.minScale}
maxScale={this.props.maxScale}
>
{this!.props!.renderImage!(image.props)}
{this!.props!.renderImage!(image.props, index)}
</ImageZoom>
);
case 'fail':
Expand All @@ -580,7 +580,7 @@ export default class ImageViewer extends React.Component<Props, State> {
width: this.props.failImageSource.width,
height: this.props.failImageSource.height
}
})}
}, index)}
</Wrapper>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/image-viewer.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class Props {
/**
* Render image component
*/
public renderImage?: (props: any) => React.ReactElement<any> = (props: any) => {
public renderImage?: (props: any, index: number) => React.ReactElement<any> = (props: any) => {
return React.createElement(Image, props);
};

Expand Down