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

Commit 4c988ca

Browse files
committed
fix type error
1 parent 6814cf1 commit 4c988ca

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

src/image-viewer.component.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ export default class ImageViewer extends React.Component<Props, State> {
180180
}
181181

182182
// 如果已知源图片宽高,直接设置为 success
183-
if (image.width && image.height){
184-
if(this.props.enablePreload && imageLoaded===false){
185-
Image.prefetch(image.url)
183+
if (image.width && image.height) {
184+
if (this.props.enablePreload && imageLoaded === false) {
185+
Image.prefetch(image.url);
186186
}
187187
imageStatus.width = image.width;
188188
imageStatus.height = image.height;
@@ -216,13 +216,13 @@ export default class ImageViewer extends React.Component<Props, State> {
216216
}
217217

218218
/**
219-
* 预加载图片
220-
*/
221-
public preloadImage = (index: number) =>{
222-
if (index < this.state.imageSizes!.length){
219+
* 预加载图片
220+
*/
221+
public preloadImage = (index: number) => {
222+
if (index < this.state.imageSizes!.length) {
223223
this.loadImage(index + 1);
224224
}
225-
}
225+
};
226226
/**
227227
* 触发溢出水平滚动
228228
*/
@@ -526,8 +526,8 @@ export default class ImageViewer extends React.Component<Props, State> {
526526
...image.props.source
527527
};
528528
}
529-
if (this.props.enablePreload){
530-
this.preloadImage(this.state.currentShowIndex||0)
529+
if (this.props.enablePreload) {
530+
this.preloadImage(this.state.currentShowIndex || 0);
531531
}
532532
return (
533533
<ImageZoom
@@ -548,8 +548,8 @@ export default class ImageViewer extends React.Component<Props, State> {
548548
swipeDownThreshold={this.props.swipeDownThreshold}
549549
onSwipeDown={this.handleSwipeDown}
550550
panToMove={!this.state.isShowMenu}
551-
pinchToZoom={this.props.enableImageZoom&&!this.state.isShowMenu}
552-
enableDoubleClickZoom={this.props.enableImageZoom&&!this.state.isShowMenu}
551+
pinchToZoom={this.props.enableImageZoom && !this.state.isShowMenu}
552+
enableDoubleClickZoom={this.props.enableImageZoom && !this.state.isShowMenu}
553553
doubleClickInterval={this.props.doubleClickInterval}
554554
>
555555
{this!.props!.renderImage!(image.props)}
@@ -616,7 +616,7 @@ export default class ImageViewer extends React.Component<Props, State> {
616616
</View>
617617
)}
618618
<View style={[{ bottom: 0, position: 'absolute', zIndex: 9 }, this.props.footerContainerStyle]}>
619-
{this!.props!.renderFooter!(this.state.currentShowIndex)}
619+
{this!.props!.renderFooter!(this.state.currentShowIndex || -1)}
620620
</View>
621621
</Animated.View>
622622
</Animated.View>
@@ -642,12 +642,12 @@ export default class ImageViewer extends React.Component<Props, State> {
642642
return null;
643643
}
644644

645-
if(this.props.menus) {
645+
if (this.props.menus) {
646646
return (
647-
<View style={this.styles.menuContainer}>
648-
{this.props.menus({cancel:this.handleLeaveMenu,saveToLocal:this.saveToLocal})}
649-
</View>
650-
)
647+
<View style={this.styles.menuContainer}>
648+
{this.props.menus({ cancel: this.handleLeaveMenu, saveToLocal: this.saveToLocal })}
649+
</View>
650+
);
651651
}
652652

653653
return (

src/image-viewer.type.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class Props {
101101
/**
102102
* 单击回调
103103
*/
104-
public onClick?: (close?: () => any, currentShowIndex?: number) => void = () => {
104+
public onClick?: (close?: () => any, currentShowIndex?: number) => void = () => {
105105
//
106106
};
107107

@@ -214,6 +214,8 @@ export class Props {
214214
public onChange?: (index?: number) => void = () => {
215215
//
216216
};
217+
218+
public menus?: ({ cancel, saveToLocal }: any) => React.ReactElement<any>;
217219
}
218220

219221
export class State {

0 commit comments

Comments
 (0)