Ver Fonte

修复缩放最大值的问题

MinJieLiu há 7 anos atrás
pai
commit
a3f9b96b86
3 ficheiros alterados com 12 adições e 3 exclusões
  1. 9 0
      .npmignore
  2. 1 1
      examples/simple.tsx
  3. 2 2
      src/PhotoView.tsx

+ 9 - 0
.npmignore

@@ -0,0 +1,9 @@
+.DS_STORE
+*.log
+node_modules
+/build
+/examples
+coverage
+.nyc_output
+yarn.lock
+.idea/

+ 1 - 1
examples/simple.tsx

@@ -43,7 +43,7 @@ class Example extends React.Component {
           <ImageList>
             {photoImages.map((item, index) => (
               <PhotoConsumer key={index} src={item}>
-                <SmallImage />
+                {index < 2 ? <SmallImage /> : undefined}
               </PhotoConsumer>
             ))}
           </ImageList>

+ 2 - 2
src/PhotoView.tsx

@@ -270,7 +270,7 @@ export default class PhotoView extends React.Component<
   handleUp = (newPageX: number, newPageY: number) => {
     if (this.state.touched) {
       const { onReachUp } = this.props;
-      const { width, height } = this.photoRef.state;
+      const { width, naturalWidth, height } = this.photoRef.state;
       this.setState(({
         x,
         y,
@@ -289,7 +289,7 @@ export default class PhotoView extends React.Component<
         const toScale = Math.max(
           Math.min(
             scale,
-            maxScale,
+            Math.max(maxScale, naturalWidth / width),
           ),
           minScale,
         );