diff --git a/.fatherrc.js b/.fatherrc.js
index 205e08f..7414da0 100644
--- a/.fatherrc.js
+++ b/.fatherrc.js
@@ -7,4 +7,4 @@ export default defineConfig({
output: 'es',
alias: { 'rc-util/lib': 'rc-util/es' },
},
-});
\ No newline at end of file
+});
diff --git a/LICENSE.md b/LICENSE.md
index 12189b6..69e806d 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -2,21 +2,8 @@ MIT LICENSE
Copyright (c) 2015-present Alipay.com, https://www.alipay.com/
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/docs/examples/basic.tsx b/docs/examples/basic.tsx
index 67d2b17..bf55799 100644
--- a/docs/examples/basic.tsx
+++ b/docs/examples/basic.tsx
@@ -3,7 +3,6 @@ import * as React from 'react';
import '../../assets/index.less';
import { defaultIcons } from './common';
-
export default function Base() {
return (
@@ -21,7 +20,7 @@ export default function Base() {
onVisibleChange: visible => {
console.log('visible', visible);
},
- zIndex: 9999
+ zIndex: 9999,
}}
/>
@@ -39,19 +38,19 @@ export default function Base() {
style={{
marginRight: 24,
}}
- preview={{icons: defaultIcons}}
+ preview={{ icons: defaultIcons }}
/>
);
diff --git a/docs/examples/common.tsx b/docs/examples/common.tsx
index 5ec407a..c0adb47 100644
--- a/docs/examples/common.tsx
+++ b/docs/examples/common.tsx
@@ -1,25 +1,24 @@
-
-import React from 'react';
import type { PreviewProps } from '@/Preview';
import {
- CloseOutlined,
- LeftOutlined,
- RightOutlined,
- RotateLeftOutlined,
- RotateRightOutlined,
- SwapOutlined,
- ZoomInOutlined,
- ZoomOutOutlined,
- } from '@ant-design/icons';
-
- export const defaultIcons: PreviewProps['icons'] = {
- rotateLeft: ,
- rotateRight: ,
- zoomIn: ,
- zoomOut: ,
- close: ,
- left: ,
- right: ,
- flipX: ,
- flipY: ,
- };
\ No newline at end of file
+ CloseOutlined,
+ LeftOutlined,
+ RightOutlined,
+ RotateLeftOutlined,
+ RotateRightOutlined,
+ SwapOutlined,
+ ZoomInOutlined,
+ ZoomOutOutlined,
+} from '@ant-design/icons';
+import React from 'react';
+
+export const defaultIcons: PreviewProps['icons'] = {
+ rotateLeft: ,
+ rotateRight: ,
+ zoomIn: ,
+ zoomOut: ,
+ close: ,
+ left: ,
+ right: ,
+ flipX: ,
+ flipY: ,
+};
diff --git a/docs/examples/controlled.tsx b/docs/examples/controlled.tsx
index 6ae65ac..71fce6b 100644
--- a/docs/examples/controlled.tsx
+++ b/docs/examples/controlled.tsx
@@ -1,5 +1,5 @@
-import * as React from 'react';
import Image from 'rc-image';
+import * as React from 'react';
import '../../assets/index.less';
import { defaultIcons } from './common';
diff --git a/docs/examples/controlledWithGroup.tsx b/docs/examples/controlledWithGroup.tsx
index 3120df9..2a65394 100644
--- a/docs/examples/controlledWithGroup.tsx
+++ b/docs/examples/controlledWithGroup.tsx
@@ -1,6 +1,6 @@
/* eslint-disable global-require */
-import * as React from 'react';
import Image from 'rc-image';
+import * as React from 'react';
import '../../assets/index.less';
import { defaultIcons } from './common';
diff --git a/docs/examples/fallback.tsx b/docs/examples/fallback.tsx
index 7393568..eaf56c4 100644
--- a/docs/examples/fallback.tsx
+++ b/docs/examples/fallback.tsx
@@ -1,5 +1,5 @@
-import * as React from 'react';
import Image from 'rc-image';
+import * as React from 'react';
import '../../assets/index.less';
import { defaultIcons } from './common';
diff --git a/docs/examples/placeholder.tsx b/docs/examples/placeholder.tsx
index 4faf058..591bbc9 100644
--- a/docs/examples/placeholder.tsx
+++ b/docs/examples/placeholder.tsx
@@ -1,5 +1,5 @@
-import * as React from 'react';
import Image from 'rc-image';
+import * as React from 'react';
import '../../assets/index.less';
import { defaultIcons } from './common';
@@ -22,7 +22,7 @@ export default function Base() {
src={`${require('./images/placeholder.png')}?random=${random}`}
width={400}
placeholder
- preview={{icons: defaultIcons}}
+ preview={{ icons: defaultIcons }}
/>
@@ -32,7 +32,7 @@ export default function Base() {
// eslint-disable-next-line global-require
src={`${require('./images/placeholder.png')}?random=${random + 1}`}
width={400}
- preview={{icons: defaultIcons}}
+ preview={{ icons: defaultIcons }}
placeholder={
PreviewGroup
-
+
diff --git a/now.json b/now.json
index 70106d2..4d507fa 100644
--- a/now.json
+++ b/now.json
@@ -8,7 +8,5 @@
"config": { "distDir": "dist" }
}
],
- "routes": [
- { "src": "/(.*)", "dest": "/dist/$1" }
- ]
+ "routes": [{ "src": "/(.*)", "dest": "/dist/$1" }]
}
diff --git a/package.json b/package.json
index abd479b..73d7cf8 100644
--- a/package.json
+++ b/package.json
@@ -8,6 +8,15 @@
"react-image",
"image"
],
+ "homepage": "http://github.com/react-component/image",
+ "bugs": {
+ "url": "http://github.com/react-component/image/issues"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:react-component/image.git"
+ },
+ "license": "MIT",
"main": "./lib/index",
"module": "./es/index",
"types": "./lib/index.d.ts",
@@ -16,30 +25,17 @@
"es",
"lib"
],
- "homepage": "http://github.com/react-component/image",
- "repository": {
- "type": "git",
- "url": "git@github.com:react-component/image.git"
- },
- "bugs": {
- "url": "http://github.com/react-component/image/issues"
- },
- "license": "MIT",
"scripts": {
- "start": "dumi dev",
+ "compile": "father build && lessc assets/index.less assets/index.css",
+ "coverage": "rc-test --coverage",
"docs:build": "dumi build",
"docs:deploy": "gh-pages -d docs-dist",
- "compile": "father build && lessc assets/index.less assets/index.css",
- "prepublishOnly": "npm run compile && np --yolo --no-publish --any-branch",
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
+ "now-build": "npm run docs:build",
+ "prepublishOnly": "npm run compile && np --yolo --no-publish --any-branch",
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
- "test": "rc-test",
- "coverage": "rc-test --coverage",
- "now-build": "npm run docs:build"
- },
- "peerDependencies": {
- "react": ">=16.9.0",
- "react-dom": ">=16.9.0"
+ "start": "dumi dev",
+ "test": "rc-test"
},
"dependencies": {
"@babel/runtime": "^7.11.2",
@@ -69,5 +65,9 @@
"react": "^18.0.0",
"react-dom": "^18.0.0",
"typescript": "^5.3.3"
+ },
+ "peerDependencies": {
+ "react": ">=16.9.0",
+ "react-dom": ">=16.9.0"
}
}
diff --git a/src/Image.tsx b/src/Image.tsx
index 797c0e2..2f5c3c1 100644
--- a/src/Image.tsx
+++ b/src/Image.tsx
@@ -1,19 +1,19 @@
import cn from 'classnames';
import type { IDialogPropTypes } from 'rc-dialog/lib/IDialogPropTypes';
import { getOffset } from 'rc-util/lib/Dom/css';
-import useMergedState from 'rc-util/lib/hooks/useMergedState';
import type { GetContainer } from 'rc-util/lib/PortalWrapper';
+import useMergedState from 'rc-util/lib/hooks/useMergedState';
import * as React from 'react';
import { useContext, useMemo, useState } from 'react';
+import type { PreviewProps, ToolbarRenderInfoType } from './Preview';
+import Preview from './Preview';
+import PreviewGroup from './PreviewGroup';
import { COMMON_PROPS } from './common';
import { PreviewGroupContext } from './context';
import type { TransformType } from './hooks/useImageTransform';
import useRegisterImage from './hooks/useRegisterImage';
import useStatus from './hooks/useStatus';
import type { ImageElementProps } from './interface';
-import type { PreviewProps, ToolbarRenderInfoType } from './Preview';
-import Preview from './Preview';
-import PreviewGroup from './PreviewGroup';
export interface ImgInfo {
url: string;
diff --git a/src/Operations.tsx b/src/Operations.tsx
index 32cec8d..e87cb06 100644
--- a/src/Operations.tsx
+++ b/src/Operations.tsx
@@ -4,10 +4,10 @@ import CSSMotion from 'rc-motion';
import KeyCode from 'rc-util/lib/KeyCode';
import * as React from 'react';
import { useContext } from 'react';
+import type { ImgInfo } from './Image';
+import type { PreviewProps, ToolbarRenderInfoType } from './Preview';
import { PreviewGroupContext } from './context';
import type { TransformType } from './hooks/useImageTransform';
-import type { PreviewProps, ToolbarRenderInfoType } from './Preview';
-import type { ImgInfo } from './Image';
interface OperationsProps
extends Pick<
diff --git a/src/Preview.tsx b/src/Preview.tsx
index db0b990..81a7640 100644
--- a/src/Preview.tsx
+++ b/src/Preview.tsx
@@ -4,15 +4,15 @@ import Dialog from 'rc-dialog';
import addEventListener from 'rc-util/lib/Dom/addEventListener';
import KeyCode from 'rc-util/lib/KeyCode';
import React, { useContext, useEffect, useRef, useState } from 'react';
+import type { ImgInfo } from './Image';
+import Operations from './Operations';
import { PreviewGroupContext } from './context';
import type { TransformAction, TransformType } from './hooks/useImageTransform';
import useImageTransform from './hooks/useImageTransform';
import useMouseEvent from './hooks/useMouseEvent';
-import useTouchEvent from './hooks/useTouchEvent';
import useStatus from './hooks/useStatus';
-import Operations from './Operations';
+import useTouchEvent from './hooks/useTouchEvent';
import { BASE_SCALE_RATIO } from './previewConfig';
-import type { ImgInfo } from './Image';
export type ToolbarRenderInfoType = {
icons: {
diff --git a/src/PreviewGroup.tsx b/src/PreviewGroup.tsx
index 7485d44..22fd7ae 100644
--- a/src/PreviewGroup.tsx
+++ b/src/PreviewGroup.tsx
@@ -1,18 +1,18 @@
import useMergedState from 'rc-util/lib/hooks/useMergedState';
import * as React from 'react';
import { useState } from 'react';
+import { type ImagePreviewType } from './Image';
+import type { PreviewProps, ToolbarRenderInfoType } from './Preview';
+import Preview from './Preview';
import { PreviewGroupContext } from './context';
import type { TransformType } from './hooks/useImageTransform';
import usePreviewItems from './hooks/usePreviewItems';
-import { type ImagePreviewType } from './Image';
import type { ImageElementProps, OnGroupPreview } from './interface';
-import type { PreviewProps, ToolbarRenderInfoType } from './Preview';
-import Preview from './Preview';
export interface PreviewGroupPreview
extends Omit<
ImagePreviewType,
- | 'mask' | 'maskClassName' | 'onVisibleChange' | 'toolbarRender' | 'imageRender'
+ 'mask' | 'maskClassName' | 'onVisibleChange' | 'toolbarRender' | 'imageRender'
> {
/**
* If Preview the show img index
diff --git a/src/hooks/useImageTransform.ts b/src/hooks/useImageTransform.ts
index cadd0eb..4e1e4b6 100644
--- a/src/hooks/useImageTransform.ts
+++ b/src/hooks/useImageTransform.ts
@@ -92,7 +92,13 @@ export default function useImageTransform(
};
/** Scale according to the position of centerX and centerY */
- const dispatchZoomChange: DispatchZoomChangeFunc = (ratio, action, centerX?, centerY?, isTouch?) => {
+ const dispatchZoomChange: DispatchZoomChangeFunc = (
+ ratio,
+ action,
+ centerX?,
+ centerY?,
+ isTouch?,
+ ) => {
const { width, height, offsetWidth, offsetHeight, offsetLeft, offsetTop } = imgRef.current;
let newRatio = ratio;
diff --git a/src/hooks/useMouseEvent.ts b/src/hooks/useMouseEvent.ts
index e152f33..624e52c 100644
--- a/src/hooks/useMouseEvent.ts
+++ b/src/hooks/useMouseEvent.ts
@@ -1,10 +1,14 @@
-import type React from 'react';
-import { useState, useRef, useEffect } from 'react';
import addEventListener from 'rc-util/lib/Dom/addEventListener';
import { warning } from 'rc-util/lib/warning';
+import type React from 'react';
+import { useEffect, useRef, useState } from 'react';
import getFixScaleEleTransPosition from '../getFixScaleEleTransPosition';
import { BASE_SCALE_RATIO, WHEEL_MAX_SCALE_RATIO } from '../previewConfig';
-import type { TransformType, UpdateTransformFunc, DispatchZoomChangeFunc } from './useImageTransform';
+import type {
+ DispatchZoomChangeFunc,
+ TransformType,
+ UpdateTransformFunc,
+} from './useImageTransform';
export default function useMouseEvent(
imgRef: React.MutableRefObject,
@@ -25,7 +29,7 @@ export default function useMouseEvent(
transformY: 0,
});
- const onMouseDown: React.MouseEventHandler = (event) => {
+ const onMouseDown: React.MouseEventHandler = event => {
// Only allow main button
if (!movable || event.button !== 0) return;
event.preventDefault();
@@ -39,7 +43,7 @@ export default function useMouseEvent(
setMoving(true);
};
- const onMouseMove: React.MouseEventHandler = (event) => {
+ const onMouseMove: React.MouseEventHandler = event => {
if (visible && isMoving) {
updateTransform(
{
@@ -132,5 +136,5 @@ export default function useMouseEvent(
onMouseMove,
onMouseUp,
onWheel,
- }
-};
+ };
+}
diff --git a/src/hooks/usePreviewItems.ts b/src/hooks/usePreviewItems.ts
index 82df54c..ac65258 100644
--- a/src/hooks/usePreviewItems.ts
+++ b/src/hooks/usePreviewItems.ts
@@ -1,4 +1,5 @@
import * as React from 'react';
+import type { GroupConsumerProps } from '../PreviewGroup';
import { COMMON_PROPS } from '../common';
import type {
ImageElementProps,
@@ -6,7 +7,6 @@ import type {
PreviewImageElementProps,
RegisterImage,
} from '../interface';
-import type { GroupConsumerProps } from '../PreviewGroup';
export type Items = Omit[];
diff --git a/src/hooks/useTouchEvent.ts b/src/hooks/useTouchEvent.ts
index 1de9632..b89960b 100644
--- a/src/hooks/useTouchEvent.ts
+++ b/src/hooks/useTouchEvent.ts
@@ -1,8 +1,12 @@
-import type React from 'react';
-import { useState, useRef, useEffect } from 'react';
import addEventListener from 'rc-util/lib/Dom/addEventListener';
+import type React from 'react';
+import { useEffect, useRef, useState } from 'react';
import getFixScaleEleTransPosition from '../getFixScaleEleTransPosition';
-import type { TransformType, UpdateTransformFunc, DispatchZoomChangeFunc } from './useImageTransform';
+import type {
+ DispatchZoomChangeFunc,
+ TransformType,
+ UpdateTransformFunc,
+} from './useImageTransform';
type Point = {
x: number;
@@ -77,17 +81,17 @@ export default function useTouchEvent(
updateTouchPointInfo({
point1: { x: touches[0].clientX, y: touches[0].clientY },
point2: { x: touches[1].clientX, y: touches[1].clientY },
- eventType: 'touchZoom'
- })
+ eventType: 'touchZoom',
+ });
} else {
// touch move
updateTouchPointInfo({
point1: {
x: touches[0].clientX - x,
- y: touches[0].clientY - y
+ y: touches[0].clientY - y,
},
- eventType: 'move'
- })
+ eventType: 'move',
+ });
}
};
@@ -99,11 +103,11 @@ export default function useTouchEvent(
// touch zoom
const newPoint1 = {
x: touches[0].clientX,
- y: touches[0].clientY
+ y: touches[0].clientY,
};
const newPoint2 = {
x: touches[1].clientX,
- y: touches[1].clientY
+ y: touches[1].clientY,
};
const [centerX, centerY] = getCenter(point1, point2, newPoint1, newPoint2);
const ratio = getDistance(newPoint1, newPoint2) / getDistance(point1, point2);
@@ -112,7 +116,7 @@ export default function useTouchEvent(
updateTouchPointInfo({
point1: newPoint1,
point2: newPoint2,
- eventType: 'touchZoom'
+ eventType: 'touchZoom',
});
} else if (eventType === 'move') {
// touch move
@@ -129,7 +133,7 @@ export default function useTouchEvent(
const onTouchEnd = () => {
if (!visible) return;
-
+
if (isTouching) {
setIsTouching(false);
}
@@ -139,7 +143,7 @@ export default function useTouchEvent(
if (minScale > scale) {
/** When the scaling ratio is less than the minimum scaling ratio, reset the scaling ratio */
return updateTransform({ x: 0, y: 0, scale: minScale }, 'touchZoom');
- }
+ }
const width = imgRef.current.offsetWidth * scale;
const height = imgRef.current.offsetHeight * scale;
@@ -162,17 +166,19 @@ export default function useTouchEvent(
useEffect(() => {
let onTouchMoveListener;
if (visible && movable) {
- onTouchMoveListener = addEventListener(window, 'touchmove', (e) => e.preventDefault(), { passive: false });
+ onTouchMoveListener = addEventListener(window, 'touchmove', e => e.preventDefault(), {
+ passive: false,
+ });
}
return () => {
onTouchMoveListener?.remove();
- }
+ };
}, [visible, movable]);
-
+
return {
isTouching,
onTouchStart,
onTouchMove,
onTouchEnd,
- }
-};
+ };
+}
diff --git a/tests/basic.test.tsx b/tests/basic.test.tsx
index 44f2618..a58d5e7 100644
--- a/tests/basic.test.tsx
+++ b/tests/basic.test.tsx
@@ -1,5 +1,5 @@
+import { fireEvent, render } from '@testing-library/react';
import React from 'react';
-import { render, fireEvent } from '@testing-library/react';
import Image from '../src';
describe('Basic', () => {
diff --git a/tests/placeholder.test.tsx b/tests/placeholder.test.tsx
index ef7b834..8a78460 100644
--- a/tests/placeholder.test.tsx
+++ b/tests/placeholder.test.tsx
@@ -1,6 +1,6 @@
-import React from 'react';
-import { render, fireEvent, act } from '@testing-library/react';
+import { act, fireEvent, render } from '@testing-library/react';
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
+import React from 'react';
import Image from '../src';
describe('Placeholder', () => {
diff --git a/tests/preview.test.tsx b/tests/preview.test.tsx
index 73fbd6f..b402121 100644
--- a/tests/preview.test.tsx
+++ b/tests/preview.test.tsx
@@ -811,7 +811,12 @@ describe('Preview', () => {
});
expect(document.querySelectorAll('.rc-image-preview-operations-operation')).toHaveLength(2);
- expect(printImage).toHaveBeenCalledWith({ "alt": "alt", "height": 200, "url": "https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png", "width": 200 });
+ expect(printImage).toHaveBeenCalledWith({
+ alt: 'alt',
+ height: 200,
+ url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
+ width: 200,
+ });
});
it('onTransform should be triggered when transform change', () => {
diff --git a/tests/previewGroup.test.tsx b/tests/previewGroup.test.tsx
index 3b604be..3822680 100644
--- a/tests/previewGroup.test.tsx
+++ b/tests/previewGroup.test.tsx
@@ -271,13 +271,19 @@ describe('PreviewGroup', () => {
it('album mode: object item', () => {
const { container } = render(
-
+
,
);
@@ -327,13 +333,20 @@ describe('PreviewGroup', () => {
it('onTransform should be triggered when switch', () => {
const onTransform = jest.fn();
render(
- ,
+ ,
);
fireEvent.click(document.querySelector('.rc-image-preview-operations-operation-flipY'));
act(() => {
diff --git a/tests/previewTouch.test.tsx b/tests/previewTouch.test.tsx
index 4edee9a..aa4ede5 100644
--- a/tests/previewTouch.test.tsx
+++ b/tests/previewTouch.test.tsx
@@ -1,6 +1,6 @@
-import React from 'react';
import { act, fireEvent, render } from '@testing-library/react';
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
+import React from 'react';
import Image from '../src';
describe('Touch Events', () => {
@@ -22,10 +22,10 @@ describe('Touch Events', () => {
const previewImgDom = document.querySelector('.rc-image-preview-img');
fireEvent.touchStart(previewImgDom, {
- touches: [{ clientX: 0, clientY: 0 }]
+ touches: [{ clientX: 0, clientY: 0 }],
});
fireEvent.touchMove(previewImgDom, {
- touches: [{ clientX: 50, clientY: 50 }]
+ touches: [{ clientX: 50, clientY: 50 }],
});
act(() => {
@@ -47,7 +47,7 @@ describe('Touch Events', () => {
// Correct the position when the image moves out of the current window
expect(previewImgDom).toHaveStyle({
transform: 'translate3d(0px, 0px, 0) scale3d(1, 1, 1) rotate(0deg)',
- transitionDuration: undefined
+ transitionDuration: undefined,
});
});
@@ -64,13 +64,13 @@ describe('Touch Events', () => {
touches: [
{ clientX: 40, clientY: 40 },
{ clientX: 60, clientY: 60 },
- ]
+ ],
});
fireEvent.touchMove(previewImgDom, {
touches: [
{ clientX: 30, clientY: 30 },
{ clientX: 70, clientY: 70 },
- ]
+ ],
});
act(() => {
@@ -82,12 +82,12 @@ describe('Touch Events', () => {
// Disable transition during image zooming
transitionDuration: '0s',
});
-
+
fireEvent.touchEnd(previewImgDom);
expect(previewImgDom).toHaveStyle({
transform: 'translate3d(-50px, -50px, 0) scale3d(2, 2, 1) rotate(0deg)',
- transitionDuration: undefined
+ transitionDuration: undefined,
});
});
@@ -108,18 +108,18 @@ describe('Touch Events', () => {
fireEvent.click(container.querySelector('.rc-image'));
const previewImgDom = document.querySelector('.rc-image-preview-img');
-
+
fireEvent.touchStart(previewImgDom, {
touches: [
{ clientX: 40, clientY: 40 },
{ clientX: 60, clientY: 60 },
- ]
+ ],
});
fireEvent.touchMove(previewImgDom, {
touches: [
{ clientX: 10, clientY: 10 },
{ clientX: 70, clientY: 70 },
- ]
+ ],
});
act(() => {
@@ -135,7 +135,7 @@ describe('Touch Events', () => {
touches: [
{ clientX: 10, clientY: 10 },
{ clientX: 70, clientY: 70 },
- ]
+ ],
});
imgEleMock.mockRestore();
@@ -155,19 +155,19 @@ describe('Touch Events', () => {
touches: [
{ clientX: 20, clientY: 40 },
{ clientX: 20, clientY: 60 },
- ]
+ ],
});
fireEvent.touchMove(previewImgDom, {
touches: [
{ clientX: 20, clientY: 45 },
{ clientX: 20, clientY: 55 },
- ]
+ ],
});
act(() => {
jest.runAllTimers();
});
-
+
fireEvent.touchEnd(previewImgDom);
act(() => {
diff --git a/update-example.js b/update-example.js
index f8b9e90..720f289 100644
--- a/update-example.js
+++ b/update-example.js
@@ -20,12 +20,12 @@ paths.forEach(path => {
`,
'utf8',
- function(error) {
- if(error){
+ function (error) {
+ if (error) {
console.log(error);
return false;
}
console.log(`${name} 更新成功~`);
- }
- )
+ },
+ );
});