MinJieLiu преди 7 години
родител
ревизия
a86aaacbcc
променени са 1 файла, в които са добавени 8 реда и са изтрити 6 реда
  1. 8 6
      src/PhotoView.tsx

+ 8 - 6
src/PhotoView.tsx

@@ -105,6 +105,8 @@ export default class PhotoView extends React.Component<
   handleMove = (newPageX: number, newPageY: number, touchLength: number = 0) => {
     if (this.state.touched) {
       this.setState(({
+        x,
+        y,
         pageX,
         pageY,
         lastX,
@@ -112,16 +114,16 @@ export default class PhotoView extends React.Component<
         scale,
         lastTouchLength,
       }) => {
-        const toScale = scale + (touchLength - lastTouchLength) / 100 / 2 * scale;
+        const offsetScale = (touchLength - lastTouchLength) / 100 / 2 * scale;
         return {
           lastTouchLength: touchLength,
           ...getPositionOnMoveOrScale({
-            x: newPageX - pageX + lastX,
-            y: newPageY - pageY + lastY,
-            pageX,
-            pageY,
+            x: touchLength ? x : newPageX - pageX + lastX,
+            y: touchLength ? y : newPageY - pageY + lastY,
+            pageX: newPageX,
+            pageY: newPageY,
             fromScale: scale,
-            toScale,
+            toScale: scale + offsetScale,
           }),
         };
       });