Skip to content

Commit

Permalink
chore: rename to movable
Browse files Browse the repository at this point in the history
  • Loading branch information
linxianxi committed Jul 25, 2023
1 parent 2c573f9 commit 12aa5bb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default () => (
| visible | boolean | - | Whether the preview is open or not |
| closeIcon | React.ReactNode | - | Custom close icon |
| src | string | - | Customize preview src |
| draggable | boolean | true | Enable drag |
| movable | boolean | true | Enable drag |
| scaleStep | number | 0.5 | The number to which the scale is increased or decreased |
| minScale | number | 1 | Min scale |
| maxScale | number | 50 | Max scale |
Expand Down Expand Up @@ -121,7 +121,7 @@ export default () => (
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| visible | boolean | - | Whether the preview is open or not |
| draggable | boolean | true | Enable drag |
| movable | boolean | true | Enable drag |
| current | number | - | Current index |
| closeIcon | React.ReactNode | - | Custom close icon |
| scaleStep | number | 0.5 | The number to which the scale is increased or decreased |
Expand Down
6 changes: 3 additions & 3 deletions src/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface ImagePreviewType
maskClassName?: string;
icons?: PreviewProps['icons'];
scaleStep?: number;
draggable?: boolean;
movable?: boolean;
imageRender?: (
originalNode: React.ReactNode,
info: { transform: TransformType },
Expand Down Expand Up @@ -97,7 +97,7 @@ const ImageInternal: CompoundedComponent<ImageProps> = props => {
getContainer: getPreviewContainer = undefined,
mask: previewMask,
maskClassName,
draggable,
movable,
icons,
scaleStep,
minScale,
Expand Down Expand Up @@ -236,7 +236,7 @@ const ImageInternal: CompoundedComponent<ImageProps> = props => {
fallback={fallback}
getContainer={getPreviewContainer}
icons={icons}
draggable={draggable}
movable={movable}
scaleStep={scaleStep}
minScale={minScale}
maxScale={maxScale}
Expand Down
10 changes: 5 additions & 5 deletions src/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface PreviewProps extends Omit<IDialogPropTypes, 'onClose'> {
src?: string;
alt?: string;
fallback?: string;
draggable?: boolean;
movable?: boolean;
rootClassName?: string;
icons?: {
rotateLeft?: React.ReactNode;
Expand Down Expand Up @@ -99,7 +99,7 @@ const Preview: React.FC<PreviewProps> = props => {
src,
alt,
fallback,
draggable = true,
movable = true,
onClose,
visible,
icons = {},
Expand Down Expand Up @@ -231,7 +231,7 @@ const Preview: React.FC<PreviewProps> = props => {

const onMouseDown: React.MouseEventHandler<HTMLDivElement> = event => {
// Only allow main button
if (!draggable || event.button !== 0) return;
if (!movable || event.button !== 0) return;
event.preventDefault();
event.stopPropagation();
downPositionRef.current = {
Expand Down Expand Up @@ -300,7 +300,7 @@ const Preview: React.FC<PreviewProps> = props => {
let onMouseUpListener;
let onMouseMoveListener;

if (draggable) {
if (movable) {
onMouseUpListener = addEventListener(window, 'mouseup', onMouseUp, false);
onMouseMoveListener = addEventListener(window, 'mousemove', onMouseMove, false);

Expand All @@ -325,7 +325,7 @@ const Preview: React.FC<PreviewProps> = props => {
/* istanbul ignore next */
onTopMouseMoveListener?.remove();
};
}, [visible, isMoving, x, y, rotate, draggable]);
}, [visible, isMoving, x, y, rotate, movable]);

useEffect(() => {
const onKeyDownListener = addEventListener(window, 'keydown', onKeyDown, false);
Expand Down
4 changes: 2 additions & 2 deletions src/PreviewGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Group: React.FC<GroupConsumerProps> = ({
onVisibleChange,
getContainer,
current: currentIndex,
draggable,
movable,
minScale,
maxScale,
countRender,
Expand Down Expand Up @@ -134,7 +134,7 @@ const Group: React.FC<GroupConsumerProps> = ({
{children}
<Preview
aria-hidden={!isShowPreview}
draggable={draggable}
movable={movable}
visible={isShowPreview}
prefixCls={previewPrefixCls}
closeIcon={closeIcon}
Expand Down
2 changes: 1 addition & 1 deletion src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ImageElementProps } from './interface';
export const COMMON_PROPS: (keyof Omit<ImageElementProps, 'src'>)[] = [
'crossOrigin',
'decoding',
'draggable',
'movable',
'loading',
'referrerPolicy',
'sizes',
Expand Down
2 changes: 1 addition & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type ImageElementProps = Pick<
| 'src'
| 'crossOrigin'
| 'decoding'
| 'draggable'
| 'movable'
| 'loading'
| 'referrerPolicy'
| 'sizes'
Expand Down

0 comments on commit 12aa5bb

Please sign in to comment.