浏览代码

feat: 文档补全以及格式化

chenkan 5 年之前
父节点
当前提交
e2ce830ae9
共有 4 个文件被更改,包括 8 次插入8 次删除
  1. 1 1
      README.md
  2. 5 5
      src/Photo.tsx
  3. 1 1
      src/PhotoView.tsx
  4. 1 1
      src/types.ts

+ 1 - 1
README.md

@@ -83,7 +83,7 @@ function ImageView() {
 | viewClassName  | string                            | 否   | 图片容器 className         |
 | imageClassName | string                            | 否   | 图片 className             |
 | loadingElement | JSX.Element                       | 否   | 自定义 loading             |
-| brokenElement  | JSX.Element                       | 否   | 加载失败 Element           |
+| brokenElement  | JSX.Element | ((photoProps: brokenElementDataType) => JSX.Element)                       | 否   | 加载失败 Element           |
 
 #### PhotoConsumer
 

+ 5 - 5
src/Photo.tsx

@@ -17,10 +17,10 @@ export interface IPhotoProps extends React.HTMLAttributes<any> {
   className?: string;
   onImageLoad: (PhotoParams, callback?: Function) => void;
   loadingElement?: JSX.Element;
-  brokenElement?: JSX.Element | ((photoProps: brokenElementDataType)=>JSX.Element);
+  brokenElement?: JSX.Element | ((photoProps: brokenElementDataType) => JSX.Element);
 }
 
-const Photo: React.FC<IPhotoProps> = (props) => {
+const Photo: React.FC<IPhotoProps> = props => {
   const {
     src,
     intro,
@@ -80,12 +80,12 @@ const Photo: React.FC<IPhotoProps> = (props) => {
     }
     return loadingElement || <Spinner />;
   }
-  if(brokenElement){
-    if(typeof brokenElement === 'function'){
+  if (brokenElement) {
+    if (typeof brokenElement === 'function') {
       return brokenElement({
         src,
         intro,
-      })
+      });
     }
     return brokenElement;
   }

+ 1 - 1
src/PhotoView.tsx

@@ -38,7 +38,7 @@ export interface IPhotoViewProps {
   // 自定义 loading
   loadingElement?: JSX.Element;
   // 加载失败 Element
-  brokenElement?: JSX.Element | ((photoProps: brokenElementDataType)=>JSX.Element);
+  brokenElement?: JSX.Element | ((photoProps: brokenElementDataType) => JSX.Element);
   // 旋转状态
   rotate: number;
 

+ 1 - 1
src/types.ts

@@ -62,7 +62,7 @@ export interface IPhotoProviderBase {
   // 自定义 loading
   loadingElement?: JSX.Element;
   // 加载失败 Element
-  brokenElement?: JSX.Element | ((photoProps: brokenElementDataType)=>JSX.Element);
+  brokenElement?: JSX.Element | ((photoProps: brokenElementDataType) => JSX.Element);
 }
 
 export type ReachMoveFunction = (reachState: ReachTypeEnum, clientX: number, clientY: number, scale?: number) => void;