@v-c/image 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Image.js +1 -1
- package/dist/Preview/index.js +1 -1
- package/dist/portal/dist/Portal.js +3 -2
- package/dist/util/dist/Dom/findDOMNode.js +20 -0
- package/dist/util/dist/getScrollBarSize.js +42 -44
- package/package.json +12 -12
- package/LICENSE +0 -21
- package/dist/Image.cjs +0 -231
- package/dist/Preview/CloseBtn.cjs +0 -44
- package/dist/Preview/Footer.cjs +0 -234
- package/dist/Preview/PrevNext.cjs +0 -59
- package/dist/Preview/index.cjs +0 -404
- package/dist/PreviewGroup.cjs +0 -138
- package/dist/common.cjs +0 -13
- package/dist/context.cjs +0 -11
- package/dist/getFixScaleEleTransPosition.cjs +0 -28
- package/dist/hooks/useImageTransform.cjs +0 -99
- package/dist/hooks/useMouseEvent.cjs +0 -96
- package/dist/hooks/usePreviewItems.cjs +0 -48
- package/dist/hooks/useRegisterImage.cjs +0 -28
- package/dist/hooks/useStatus.cjs +0 -49
- package/dist/hooks/useTouchEvent.cjs +0 -125
- package/dist/index.cjs +0 -11
- package/dist/interface.cjs +0 -1
- package/dist/portal/dist/Context.cjs +0 -12
- package/dist/portal/dist/Portal.cjs +0 -100
- package/dist/portal/dist/index.cjs +0 -3
- package/dist/portal/dist/useDom.cjs +0 -47
- package/dist/portal/dist/useEscKeyDown.cjs +0 -57
- package/dist/portal/dist/useScrollLocker.cjs +0 -28
- package/dist/portal/dist/util.cjs +0 -4
- package/dist/previewConfig.cjs +0 -5
- package/dist/util/dist/Dom/canUseDom.cjs +0 -4
- package/dist/util/dist/Dom/contains.cjs +0 -11
- package/dist/util/dist/Dom/dynamicCSS.cjs +0 -80
- package/dist/util/dist/KeyCode.cjs +0 -81
- package/dist/util/dist/RenderComponent.cjs +0 -29
- package/dist/util/dist/classnames.cjs +0 -36
- package/dist/util/dist/getScrollBarSize.cjs +0 -53
- package/dist/util/dist/hooks/useControlledState.cjs +0 -1
- package/dist/util/dist/hooks/useId.cjs +0 -5
- package/dist/util/dist/hooks/useMergedState.cjs +0 -24
- package/dist/util/dist/index.cjs +0 -8
- package/dist/util/dist/isEqual.cjs +0 -27
- package/dist/util/dist/omit.cjs +0 -8
- package/dist/util/dist/pickAttrs.cjs +0 -39
- package/dist/util/dist/props-util/index.cjs +0 -47
- package/dist/util/dist/raf.cjs +0 -36
- package/dist/util/dist/type.cjs +0 -2
- package/dist/util/dist/utils/transition.cjs +0 -21
- package/dist/util/dist/warning.cjs +0 -37
- package/dist/util.cjs +0 -27
package/dist/Preview/Footer.cjs
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_classnames = require("../util/dist/classnames.cjs");
|
|
6
|
-
require("../util/dist/index.cjs");
|
|
7
|
-
let vue = require("vue");
|
|
8
|
-
var Footer = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
9
|
-
const renderOperation = ({ type, disabled, onClick, icon }) => {
|
|
10
|
-
const actionCls = `${props.prefixCls}-actions-action`;
|
|
11
|
-
return (0, vue.createVNode)("div", {
|
|
12
|
-
"key": type,
|
|
13
|
-
"class": require_classnames.clsx(actionCls, `${actionCls}-${type}`, { [`${actionCls}-disabled`]: !!disabled }),
|
|
14
|
-
"onClick": () => {
|
|
15
|
-
if (!disabled) onClick();
|
|
16
|
-
}
|
|
17
|
-
}, [icon]);
|
|
18
|
-
};
|
|
19
|
-
return () => {
|
|
20
|
-
const { prefixCls, showProgress, current, count, showSwitch, classNames, styles, icons, image, transform, countRender, actionsRender, scale, minScale, maxScale, onActive, onFlipY, onFlipX, onRotateLeft, onRotateRight, onZoomOut, onZoomIn, onClose, onReset } = props;
|
|
21
|
-
const progressNode = showProgress && (0, vue.createVNode)("div", { "class": `${prefixCls}-progress` }, [countRender ? countRender(current + 1, count) : (0, vue.createVNode)("bdi", null, [`${current + 1} / ${count}`])]);
|
|
22
|
-
const switchPrevNode = showSwitch ? renderOperation({
|
|
23
|
-
icon: icons?.prev ?? icons?.left,
|
|
24
|
-
onClick: () => onActive(-1),
|
|
25
|
-
type: "prev",
|
|
26
|
-
disabled: current === 0
|
|
27
|
-
}) : void 0;
|
|
28
|
-
const switchNextNode = showSwitch ? renderOperation({
|
|
29
|
-
icon: icons?.next ?? icons?.right,
|
|
30
|
-
onClick: () => onActive(1),
|
|
31
|
-
type: "next",
|
|
32
|
-
disabled: current === count - 1
|
|
33
|
-
}) : void 0;
|
|
34
|
-
const flipYNode = renderOperation({
|
|
35
|
-
icon: icons?.flipY,
|
|
36
|
-
onClick: onFlipY,
|
|
37
|
-
type: "flipY"
|
|
38
|
-
});
|
|
39
|
-
const flipXNode = renderOperation({
|
|
40
|
-
icon: icons?.flipX,
|
|
41
|
-
onClick: onFlipX,
|
|
42
|
-
type: "flipX"
|
|
43
|
-
});
|
|
44
|
-
const rotateLeftNode = renderOperation({
|
|
45
|
-
icon: icons?.rotateLeft,
|
|
46
|
-
onClick: onRotateLeft,
|
|
47
|
-
type: "rotateLeft"
|
|
48
|
-
});
|
|
49
|
-
const rotateRightNode = renderOperation({
|
|
50
|
-
icon: icons?.rotateRight,
|
|
51
|
-
onClick: onRotateRight,
|
|
52
|
-
type: "rotateRight"
|
|
53
|
-
});
|
|
54
|
-
const zoomOutNode = renderOperation({
|
|
55
|
-
icon: icons?.zoomOut,
|
|
56
|
-
onClick: onZoomOut,
|
|
57
|
-
type: "zoomOut",
|
|
58
|
-
disabled: scale <= minScale
|
|
59
|
-
});
|
|
60
|
-
const zoomInNode = renderOperation({
|
|
61
|
-
icon: icons?.zoomIn,
|
|
62
|
-
onClick: onZoomIn,
|
|
63
|
-
type: "zoomIn",
|
|
64
|
-
disabled: scale === maxScale
|
|
65
|
-
});
|
|
66
|
-
const actionsNode = (0, vue.createVNode)("div", {
|
|
67
|
-
"class": require_classnames.clsx(`${prefixCls}-actions`, classNames.actions),
|
|
68
|
-
"style": styles.actions
|
|
69
|
-
}, [
|
|
70
|
-
flipYNode,
|
|
71
|
-
flipXNode,
|
|
72
|
-
rotateLeftNode,
|
|
73
|
-
rotateRightNode,
|
|
74
|
-
zoomOutNode,
|
|
75
|
-
zoomInNode
|
|
76
|
-
]);
|
|
77
|
-
const renderNode = actionsRender ? actionsRender(actionsNode, {
|
|
78
|
-
icons: {
|
|
79
|
-
prevIcon: switchPrevNode,
|
|
80
|
-
nextIcon: switchNextNode,
|
|
81
|
-
flipYIcon: flipYNode,
|
|
82
|
-
flipXIcon: flipXNode,
|
|
83
|
-
rotateLeftIcon: rotateLeftNode,
|
|
84
|
-
rotateRightIcon: rotateRightNode,
|
|
85
|
-
zoomOutIcon: zoomOutNode,
|
|
86
|
-
zoomInIcon: zoomInNode
|
|
87
|
-
},
|
|
88
|
-
actions: {
|
|
89
|
-
onActive,
|
|
90
|
-
onFlipY,
|
|
91
|
-
onFlipX,
|
|
92
|
-
onRotateLeft,
|
|
93
|
-
onRotateRight,
|
|
94
|
-
onZoomOut,
|
|
95
|
-
onZoomIn,
|
|
96
|
-
onReset,
|
|
97
|
-
onClose
|
|
98
|
-
},
|
|
99
|
-
transform,
|
|
100
|
-
current,
|
|
101
|
-
total: count,
|
|
102
|
-
image
|
|
103
|
-
}) : actionsNode;
|
|
104
|
-
return (0, vue.createVNode)("div", {
|
|
105
|
-
"class": require_classnames.clsx(`${prefixCls}-footer`, classNames.footer),
|
|
106
|
-
"style": styles.footer
|
|
107
|
-
}, [progressNode, renderNode]);
|
|
108
|
-
};
|
|
109
|
-
}, {
|
|
110
|
-
props: {
|
|
111
|
-
prefixCls: {
|
|
112
|
-
type: String,
|
|
113
|
-
required: true,
|
|
114
|
-
default: void 0
|
|
115
|
-
},
|
|
116
|
-
showProgress: {
|
|
117
|
-
type: Boolean,
|
|
118
|
-
required: true,
|
|
119
|
-
default: void 0
|
|
120
|
-
},
|
|
121
|
-
countRender: {
|
|
122
|
-
type: Function,
|
|
123
|
-
required: false,
|
|
124
|
-
default: void 0
|
|
125
|
-
},
|
|
126
|
-
actionsRender: {
|
|
127
|
-
type: Function,
|
|
128
|
-
required: false,
|
|
129
|
-
default: void 0
|
|
130
|
-
},
|
|
131
|
-
current: {
|
|
132
|
-
type: Number,
|
|
133
|
-
required: true,
|
|
134
|
-
default: void 0
|
|
135
|
-
},
|
|
136
|
-
count: {
|
|
137
|
-
type: Number,
|
|
138
|
-
required: true,
|
|
139
|
-
default: void 0
|
|
140
|
-
},
|
|
141
|
-
showSwitch: {
|
|
142
|
-
type: Boolean,
|
|
143
|
-
required: true,
|
|
144
|
-
default: void 0
|
|
145
|
-
},
|
|
146
|
-
icons: {
|
|
147
|
-
required: true,
|
|
148
|
-
default: void 0
|
|
149
|
-
},
|
|
150
|
-
scale: {
|
|
151
|
-
type: Number,
|
|
152
|
-
required: true,
|
|
153
|
-
default: void 0
|
|
154
|
-
},
|
|
155
|
-
minScale: {
|
|
156
|
-
type: Number,
|
|
157
|
-
required: true,
|
|
158
|
-
default: void 0
|
|
159
|
-
},
|
|
160
|
-
maxScale: {
|
|
161
|
-
type: Number,
|
|
162
|
-
required: true,
|
|
163
|
-
default: void 0
|
|
164
|
-
},
|
|
165
|
-
image: {
|
|
166
|
-
type: Object,
|
|
167
|
-
required: true,
|
|
168
|
-
default: void 0
|
|
169
|
-
},
|
|
170
|
-
transform: {
|
|
171
|
-
type: Object,
|
|
172
|
-
required: true,
|
|
173
|
-
default: void 0
|
|
174
|
-
},
|
|
175
|
-
classNames: {
|
|
176
|
-
type: Object,
|
|
177
|
-
required: true,
|
|
178
|
-
default: void 0
|
|
179
|
-
},
|
|
180
|
-
styles: {
|
|
181
|
-
type: Object,
|
|
182
|
-
required: true,
|
|
183
|
-
default: void 0
|
|
184
|
-
},
|
|
185
|
-
onActive: {
|
|
186
|
-
type: Function,
|
|
187
|
-
required: true,
|
|
188
|
-
default: void 0
|
|
189
|
-
},
|
|
190
|
-
onFlipY: {
|
|
191
|
-
type: Function,
|
|
192
|
-
required: true,
|
|
193
|
-
default: void 0
|
|
194
|
-
},
|
|
195
|
-
onFlipX: {
|
|
196
|
-
type: Function,
|
|
197
|
-
required: true,
|
|
198
|
-
default: void 0
|
|
199
|
-
},
|
|
200
|
-
onRotateLeft: {
|
|
201
|
-
type: Function,
|
|
202
|
-
required: true,
|
|
203
|
-
default: void 0
|
|
204
|
-
},
|
|
205
|
-
onRotateRight: {
|
|
206
|
-
type: Function,
|
|
207
|
-
required: true,
|
|
208
|
-
default: void 0
|
|
209
|
-
},
|
|
210
|
-
onZoomOut: {
|
|
211
|
-
type: Function,
|
|
212
|
-
required: true,
|
|
213
|
-
default: void 0
|
|
214
|
-
},
|
|
215
|
-
onZoomIn: {
|
|
216
|
-
type: Function,
|
|
217
|
-
required: true,
|
|
218
|
-
default: void 0
|
|
219
|
-
},
|
|
220
|
-
onClose: {
|
|
221
|
-
type: Function,
|
|
222
|
-
required: true,
|
|
223
|
-
default: void 0
|
|
224
|
-
},
|
|
225
|
-
onReset: {
|
|
226
|
-
type: Function,
|
|
227
|
-
required: true,
|
|
228
|
-
default: void 0
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
name: "ImagePreviewFooter"
|
|
232
|
-
});
|
|
233
|
-
var Footer_default = Footer;
|
|
234
|
-
exports.default = Footer_default;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_classnames = require("../util/dist/classnames.cjs");
|
|
6
|
-
require("../util/dist/index.cjs");
|
|
7
|
-
let vue = require("vue");
|
|
8
|
-
var PrevNext = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
9
|
-
return () => {
|
|
10
|
-
const { prefixCls, onActive, current, count, icons } = props;
|
|
11
|
-
const switchCls = `${prefixCls}-switch`;
|
|
12
|
-
const prevIcon = icons.prev ?? icons.left;
|
|
13
|
-
const nextIcon = icons.next ?? icons.right;
|
|
14
|
-
const isPrevDisabled = current === 0;
|
|
15
|
-
const isNextDisabled = current === count - 1;
|
|
16
|
-
return (0, vue.createVNode)(vue.Fragment, null, [(0, vue.createVNode)("div", {
|
|
17
|
-
"class": require_classnames.clsx(switchCls, `${switchCls}-prev`, { [`${switchCls}-disabled`]: isPrevDisabled }),
|
|
18
|
-
"onClick": () => {
|
|
19
|
-
if (!isPrevDisabled) onActive(-1);
|
|
20
|
-
}
|
|
21
|
-
}, [prevIcon]), (0, vue.createVNode)("div", {
|
|
22
|
-
"class": require_classnames.clsx(switchCls, `${switchCls}-next`, { [`${switchCls}-disabled`]: isNextDisabled }),
|
|
23
|
-
"onClick": () => {
|
|
24
|
-
if (!isNextDisabled) onActive(1);
|
|
25
|
-
}
|
|
26
|
-
}, [nextIcon])]);
|
|
27
|
-
};
|
|
28
|
-
}, {
|
|
29
|
-
props: {
|
|
30
|
-
prefixCls: {
|
|
31
|
-
type: String,
|
|
32
|
-
required: true,
|
|
33
|
-
default: void 0
|
|
34
|
-
},
|
|
35
|
-
onActive: {
|
|
36
|
-
type: Function,
|
|
37
|
-
required: true,
|
|
38
|
-
default: void 0
|
|
39
|
-
},
|
|
40
|
-
current: {
|
|
41
|
-
type: Number,
|
|
42
|
-
required: true,
|
|
43
|
-
default: void 0
|
|
44
|
-
},
|
|
45
|
-
count: {
|
|
46
|
-
type: Number,
|
|
47
|
-
required: true,
|
|
48
|
-
default: void 0
|
|
49
|
-
},
|
|
50
|
-
icons: {
|
|
51
|
-
type: Object,
|
|
52
|
-
required: true,
|
|
53
|
-
default: void 0
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
name: "ImagePreviewPrevNext"
|
|
57
|
-
});
|
|
58
|
-
var PrevNext_default = PrevNext;
|
|
59
|
-
exports.default = PrevNext_default;
|
package/dist/Preview/index.cjs
DELETED
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_KeyCode = require("../util/dist/KeyCode.cjs");
|
|
6
|
-
const require_classnames = require("../util/dist/classnames.cjs");
|
|
7
|
-
require("../util/dist/index.cjs");
|
|
8
|
-
const require_context = require("../context.cjs");
|
|
9
|
-
const require_useStatus = require("../hooks/useStatus.cjs");
|
|
10
|
-
const require_canUseDom = require("../util/dist/Dom/canUseDom.cjs");
|
|
11
|
-
const require_index$1 = require("../portal/dist/index.cjs");
|
|
12
|
-
const require_transition = require("../util/dist/utils/transition.cjs");
|
|
13
|
-
const require_useImageTransform = require("../hooks/useImageTransform.cjs");
|
|
14
|
-
const require_previewConfig = require("../previewConfig.cjs");
|
|
15
|
-
const require_useMouseEvent = require("../hooks/useMouseEvent.cjs");
|
|
16
|
-
const require_useTouchEvent = require("../hooks/useTouchEvent.cjs");
|
|
17
|
-
const require_CloseBtn = require("./CloseBtn.cjs");
|
|
18
|
-
const require_Footer = require("./Footer.cjs");
|
|
19
|
-
const require_PrevNext = require("./PrevNext.cjs");
|
|
20
|
-
let vue = require("vue");
|
|
21
|
-
var Preview = /* @__PURE__ */ (0, vue.defineComponent)((props, { attrs, slots }) => {
|
|
22
|
-
const imgEl = (0, vue.shallowRef)();
|
|
23
|
-
const groupContext = require_context.usePreviewGroupContext();
|
|
24
|
-
const showLeftOrRightSwitches = (0, vue.computed)(() => !!groupContext && (props.count ?? 1) > 1);
|
|
25
|
-
const showOperationsProgress = (0, vue.computed)(() => !!groupContext && (props.count ?? 1) >= 1);
|
|
26
|
-
const enableTransition = (0, vue.shallowRef)(true);
|
|
27
|
-
(0, vue.watch)(enableTransition, async (val) => {
|
|
28
|
-
if (!val) {
|
|
29
|
-
await (0, vue.nextTick)();
|
|
30
|
-
enableTransition.value = true;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
const { transform, resetTransform, updateTransform, dispatchZoomChange } = require_useImageTransform.default(imgEl, (0, vue.computed)(() => props.minScale ?? 1), (0, vue.computed)(() => props.maxScale ?? 50), (info) => props.onTransform?.(info));
|
|
34
|
-
const { isMoving, onMouseDown, onWheel } = require_useMouseEvent.default(imgEl, (0, vue.computed)(() => props.movable ?? true), (0, vue.computed)(() => !!props.open), (0, vue.computed)(() => props.scaleStep ?? .5), transform, updateTransform, dispatchZoomChange);
|
|
35
|
-
const { isTouching, onTouchStart, onTouchMove, onTouchEnd } = require_useTouchEvent.default(imgEl, (0, vue.computed)(() => props.movable ?? true), (0, vue.computed)(() => !!props.open), (0, vue.computed)(() => props.minScale ?? 1), transform, updateTransform, dispatchZoomChange);
|
|
36
|
-
(0, vue.watch)(() => props.open, (open) => {
|
|
37
|
-
if (!open) resetTransform("close");
|
|
38
|
-
});
|
|
39
|
-
const onDoubleClick = (event) => {
|
|
40
|
-
if (!props.open) return;
|
|
41
|
-
if (transform.value.scale !== 1) updateTransform({
|
|
42
|
-
x: 0,
|
|
43
|
-
y: 0,
|
|
44
|
-
scale: 1
|
|
45
|
-
}, "doubleClick");
|
|
46
|
-
else dispatchZoomChange(1 + (props.scaleStep ?? .5), "doubleClick", event.clientX, event.clientY);
|
|
47
|
-
};
|
|
48
|
-
const onZoomIn = () => {
|
|
49
|
-
dispatchZoomChange(1 + (props.scaleStep ?? .5), "zoomIn");
|
|
50
|
-
};
|
|
51
|
-
const onZoomOut = () => {
|
|
52
|
-
dispatchZoomChange(1 / (1 + (props.scaleStep ?? .5)), "zoomOut");
|
|
53
|
-
};
|
|
54
|
-
const onRotateRight = () => {
|
|
55
|
-
updateTransform({ rotate: transform.value.rotate + 90 }, "rotateRight");
|
|
56
|
-
};
|
|
57
|
-
const onRotateLeft = () => {
|
|
58
|
-
updateTransform({ rotate: transform.value.rotate - 90 }, "rotateLeft");
|
|
59
|
-
};
|
|
60
|
-
const onFlipX = () => {
|
|
61
|
-
updateTransform({ flipX: !transform.value.flipX }, "flipX");
|
|
62
|
-
};
|
|
63
|
-
const onFlipY = () => {
|
|
64
|
-
updateTransform({ flipY: !transform.value.flipY }, "flipY");
|
|
65
|
-
};
|
|
66
|
-
const onReset = () => {
|
|
67
|
-
resetTransform("reset");
|
|
68
|
-
};
|
|
69
|
-
const onActive = (offset) => {
|
|
70
|
-
const current = props.current ?? 0;
|
|
71
|
-
const count = props.count ?? 1;
|
|
72
|
-
const nextCurrent = current + offset;
|
|
73
|
-
if (nextCurrent >= 0 && nextCurrent <= count - 1) {
|
|
74
|
-
enableTransition.value = false;
|
|
75
|
-
resetTransform(offset < 0 ? "prev" : "next");
|
|
76
|
-
props.onChange?.(nextCurrent, current);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const onKeyDown = (event) => {
|
|
80
|
-
if (!props.open) return;
|
|
81
|
-
const { key } = event;
|
|
82
|
-
if (key === require_KeyCode.KeyCodeStr.Escape) {
|
|
83
|
-
props.onClose?.();
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (showLeftOrRightSwitches.value) {
|
|
87
|
-
if (key === require_KeyCode.KeyCodeStr.ArrowLeft) onActive(-1);
|
|
88
|
-
else if (key === require_KeyCode.KeyCodeStr.ArrowRight) onActive(1);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
(0, vue.watchEffect)((onCleanup) => {
|
|
92
|
-
if (!require_canUseDom.canUseDom()) return;
|
|
93
|
-
if (props.open) window.addEventListener("keydown", onKeyDown);
|
|
94
|
-
onCleanup(() => {
|
|
95
|
-
window.removeEventListener("keydown", onKeyDown);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
const lockScroll = (0, vue.shallowRef)(false);
|
|
99
|
-
(0, vue.watch)(() => props.open, (open) => {
|
|
100
|
-
if (open) lockScroll.value = true;
|
|
101
|
-
});
|
|
102
|
-
const portalRender = (0, vue.shallowRef)(false);
|
|
103
|
-
(0, vue.watch)(() => props.open, (open) => {
|
|
104
|
-
if (open) portalRender.value = true;
|
|
105
|
-
});
|
|
106
|
-
const onVisibleChanged = (nextVisible) => {
|
|
107
|
-
if (!nextVisible) {
|
|
108
|
-
lockScroll.value = false;
|
|
109
|
-
portalRender.value = false;
|
|
110
|
-
}
|
|
111
|
-
props.afterOpenChange?.(nextVisible);
|
|
112
|
-
};
|
|
113
|
-
const setImgRef = (el) => {
|
|
114
|
-
imgEl.value = el;
|
|
115
|
-
};
|
|
116
|
-
const [getImgRef, srcAndOnload] = require_useStatus.default({
|
|
117
|
-
src: (0, vue.computed)(() => props.src),
|
|
118
|
-
fallback: (0, vue.computed)(() => props.fallback)
|
|
119
|
-
});
|
|
120
|
-
return () => {
|
|
121
|
-
const { prefixCls, rootClassName, src, alt, imageInfo, open, closeIcon, getContainer, current = 0, count = 1, countRender, motionName = "fade", imageRender, imgCommonProps, actionsRender = slots?.actionsRender, classNames = {}, styles = {}, mousePosition, zIndex, icons = {} } = props;
|
|
122
|
-
const bodyStyle = { ...styles.body ?? {} };
|
|
123
|
-
if (mousePosition) bodyStyle.transformOrigin = `${mousePosition.x}px ${mousePosition.y}px`;
|
|
124
|
-
const image = {
|
|
125
|
-
url: src || "",
|
|
126
|
-
alt: alt || "",
|
|
127
|
-
...imageInfo
|
|
128
|
-
};
|
|
129
|
-
const imgNode = (0, vue.createVNode)("img", (0, vue.mergeProps)(imgCommonProps, {
|
|
130
|
-
"src": srcAndOnload.value.src,
|
|
131
|
-
"ref": (el) => {
|
|
132
|
-
setImgRef(el);
|
|
133
|
-
getImgRef(el);
|
|
134
|
-
},
|
|
135
|
-
"width": props.width,
|
|
136
|
-
"height": props.height,
|
|
137
|
-
"class": `${prefixCls}-img`,
|
|
138
|
-
"alt": alt,
|
|
139
|
-
"onLoad": srcAndOnload.value.onLoad,
|
|
140
|
-
"style": {
|
|
141
|
-
transform: `translate3d(${transform.value.x}px, ${transform.value.y}px, 0) scale3d(${transform.value.flipX ? "-" : ""}${transform.value.scale}, ${transform.value.flipY ? "-" : ""}${transform.value.scale}, 1) rotate(${transform.value.rotate}deg)`,
|
|
142
|
-
transitionDuration: !enableTransition.value || isTouching.value ? "0s" : void 0
|
|
143
|
-
},
|
|
144
|
-
"onWheel": onWheel,
|
|
145
|
-
"onMousedown": onMouseDown,
|
|
146
|
-
"onDblclick": onDoubleClick,
|
|
147
|
-
"onTouchstart": onTouchStart,
|
|
148
|
-
"onTouchmove": onTouchMove,
|
|
149
|
-
"onTouchend": onTouchEnd,
|
|
150
|
-
"onTouchcancel": onTouchEnd
|
|
151
|
-
}), null);
|
|
152
|
-
const mergedRootStyle = {
|
|
153
|
-
...styles.root ?? {},
|
|
154
|
-
...attrs.style
|
|
155
|
-
};
|
|
156
|
-
if (zIndex) mergedRootStyle.zIndex = zIndex;
|
|
157
|
-
const mergedRootCls = require_classnames.clsx(prefixCls, rootClassName, classNames.root, { [`${prefixCls}-moving`]: isMoving.value });
|
|
158
|
-
const transitionProps = require_transition.getTransitionProps(motionName);
|
|
159
|
-
return (0, vue.createVNode)(require_index$1.src_default, {
|
|
160
|
-
"open": portalRender.value,
|
|
161
|
-
"getContainer": getContainer,
|
|
162
|
-
"autoLock": lockScroll.value
|
|
163
|
-
}, { default: () => [(0, vue.createVNode)(vue.Transition, (0, vue.mergeProps)(transitionProps, {
|
|
164
|
-
"onAfterEnter": () => onVisibleChanged(true),
|
|
165
|
-
"onAfterLeave": () => onVisibleChanged(false)
|
|
166
|
-
}), { default: () => {
|
|
167
|
-
if (!(portalRender.value && open)) return null;
|
|
168
|
-
return (0, vue.createVNode)("div", {
|
|
169
|
-
"class": mergedRootCls,
|
|
170
|
-
"style": mergedRootStyle
|
|
171
|
-
}, [
|
|
172
|
-
(0, vue.createVNode)("div", {
|
|
173
|
-
"class": require_classnames.clsx(`${prefixCls}-mask`, classNames.mask),
|
|
174
|
-
"style": styles.mask,
|
|
175
|
-
"onClick": () => props.onClose?.()
|
|
176
|
-
}, null),
|
|
177
|
-
(0, vue.createVNode)("div", {
|
|
178
|
-
"class": require_classnames.clsx(`${prefixCls}-body`, classNames.body),
|
|
179
|
-
"style": bodyStyle
|
|
180
|
-
}, [imageRender ? imageRender(imgNode, {
|
|
181
|
-
transform: transform.value,
|
|
182
|
-
image,
|
|
183
|
-
...groupContext ? { current } : {}
|
|
184
|
-
}) : imgNode]),
|
|
185
|
-
closeIcon !== false && closeIcon !== null && (0, vue.createVNode)(require_CloseBtn.default, {
|
|
186
|
-
"prefixCls": prefixCls,
|
|
187
|
-
"icon": closeIcon === true ? icons.close : closeIcon || icons.close,
|
|
188
|
-
"onClick": () => props.onClose?.()
|
|
189
|
-
}, null),
|
|
190
|
-
showLeftOrRightSwitches.value && (0, vue.createVNode)(require_PrevNext.default, {
|
|
191
|
-
"prefixCls": prefixCls,
|
|
192
|
-
"current": current,
|
|
193
|
-
"count": count,
|
|
194
|
-
"icons": icons,
|
|
195
|
-
"onActive": onActive
|
|
196
|
-
}, null),
|
|
197
|
-
(0, vue.createVNode)(require_Footer.default, {
|
|
198
|
-
"prefixCls": prefixCls,
|
|
199
|
-
"showProgress": showOperationsProgress.value,
|
|
200
|
-
"current": current,
|
|
201
|
-
"count": count,
|
|
202
|
-
"showSwitch": showLeftOrRightSwitches.value,
|
|
203
|
-
"classNames": classNames,
|
|
204
|
-
"styles": styles,
|
|
205
|
-
"image": image,
|
|
206
|
-
"transform": transform.value,
|
|
207
|
-
"icons": icons,
|
|
208
|
-
"countRender": countRender,
|
|
209
|
-
"actionsRender": actionsRender,
|
|
210
|
-
"scale": transform.value.scale,
|
|
211
|
-
"minScale": props.minScale ?? 1,
|
|
212
|
-
"maxScale": props.maxScale ?? 50,
|
|
213
|
-
"onActive": onActive,
|
|
214
|
-
"onFlipY": onFlipY,
|
|
215
|
-
"onFlipX": onFlipX,
|
|
216
|
-
"onRotateLeft": onRotateLeft,
|
|
217
|
-
"onRotateRight": onRotateRight,
|
|
218
|
-
"onZoomOut": onZoomOut,
|
|
219
|
-
"onZoomIn": onZoomIn,
|
|
220
|
-
"onClose": () => props.onClose?.(),
|
|
221
|
-
"onReset": onReset
|
|
222
|
-
}, null)
|
|
223
|
-
]);
|
|
224
|
-
} })] });
|
|
225
|
-
};
|
|
226
|
-
}, {
|
|
227
|
-
props: /* @__PURE__ */ (0, vue.mergeDefaults)({
|
|
228
|
-
prefixCls: {
|
|
229
|
-
type: String,
|
|
230
|
-
required: true,
|
|
231
|
-
default: void 0
|
|
232
|
-
},
|
|
233
|
-
classNames: {
|
|
234
|
-
type: Object,
|
|
235
|
-
required: false,
|
|
236
|
-
default: void 0
|
|
237
|
-
},
|
|
238
|
-
styles: {
|
|
239
|
-
type: Object,
|
|
240
|
-
required: false,
|
|
241
|
-
default: void 0
|
|
242
|
-
},
|
|
243
|
-
imageInfo: {
|
|
244
|
-
type: Object,
|
|
245
|
-
required: false,
|
|
246
|
-
default: void 0
|
|
247
|
-
},
|
|
248
|
-
fallback: {
|
|
249
|
-
type: String,
|
|
250
|
-
required: false,
|
|
251
|
-
default: void 0
|
|
252
|
-
},
|
|
253
|
-
imgCommonProps: {
|
|
254
|
-
type: Object,
|
|
255
|
-
required: false,
|
|
256
|
-
default: void 0
|
|
257
|
-
},
|
|
258
|
-
width: {
|
|
259
|
-
type: [String, Number],
|
|
260
|
-
required: false,
|
|
261
|
-
default: void 0
|
|
262
|
-
},
|
|
263
|
-
height: {
|
|
264
|
-
type: [String, Number],
|
|
265
|
-
required: false,
|
|
266
|
-
default: void 0
|
|
267
|
-
},
|
|
268
|
-
current: {
|
|
269
|
-
type: Number,
|
|
270
|
-
required: false,
|
|
271
|
-
default: void 0
|
|
272
|
-
},
|
|
273
|
-
count: {
|
|
274
|
-
type: Number,
|
|
275
|
-
required: false,
|
|
276
|
-
default: void 0
|
|
277
|
-
},
|
|
278
|
-
onChange: {
|
|
279
|
-
type: Function,
|
|
280
|
-
required: false,
|
|
281
|
-
default: void 0
|
|
282
|
-
},
|
|
283
|
-
onClose: {
|
|
284
|
-
type: Function,
|
|
285
|
-
required: false,
|
|
286
|
-
default: void 0
|
|
287
|
-
},
|
|
288
|
-
mousePosition: {
|
|
289
|
-
type: [null, Object],
|
|
290
|
-
required: true,
|
|
291
|
-
default: void 0
|
|
292
|
-
},
|
|
293
|
-
rootClassName: {
|
|
294
|
-
type: String,
|
|
295
|
-
required: false,
|
|
296
|
-
default: void 0
|
|
297
|
-
},
|
|
298
|
-
src: {
|
|
299
|
-
type: String,
|
|
300
|
-
required: false,
|
|
301
|
-
default: void 0
|
|
302
|
-
},
|
|
303
|
-
alt: {
|
|
304
|
-
type: String,
|
|
305
|
-
required: false,
|
|
306
|
-
default: void 0
|
|
307
|
-
},
|
|
308
|
-
scaleStep: {
|
|
309
|
-
type: Number,
|
|
310
|
-
required: false,
|
|
311
|
-
default: void 0
|
|
312
|
-
},
|
|
313
|
-
minScale: {
|
|
314
|
-
type: Number,
|
|
315
|
-
required: false,
|
|
316
|
-
default: void 0
|
|
317
|
-
},
|
|
318
|
-
maxScale: {
|
|
319
|
-
type: Number,
|
|
320
|
-
required: false,
|
|
321
|
-
default: void 0
|
|
322
|
-
},
|
|
323
|
-
motionName: {
|
|
324
|
-
type: String,
|
|
325
|
-
required: false,
|
|
326
|
-
default: void 0
|
|
327
|
-
},
|
|
328
|
-
open: {
|
|
329
|
-
type: Boolean,
|
|
330
|
-
required: false,
|
|
331
|
-
default: void 0
|
|
332
|
-
},
|
|
333
|
-
getContainer: {
|
|
334
|
-
required: false,
|
|
335
|
-
default: void 0
|
|
336
|
-
},
|
|
337
|
-
zIndex: {
|
|
338
|
-
type: Number,
|
|
339
|
-
required: false,
|
|
340
|
-
default: void 0
|
|
341
|
-
},
|
|
342
|
-
afterOpenChange: {
|
|
343
|
-
type: Function,
|
|
344
|
-
required: false,
|
|
345
|
-
default: void 0
|
|
346
|
-
},
|
|
347
|
-
movable: {
|
|
348
|
-
type: Boolean,
|
|
349
|
-
required: false,
|
|
350
|
-
default: void 0
|
|
351
|
-
},
|
|
352
|
-
icons: {
|
|
353
|
-
type: Object,
|
|
354
|
-
required: false,
|
|
355
|
-
default: void 0
|
|
356
|
-
},
|
|
357
|
-
closeIcon: {
|
|
358
|
-
type: [
|
|
359
|
-
Object,
|
|
360
|
-
Function,
|
|
361
|
-
String,
|
|
362
|
-
Number,
|
|
363
|
-
null,
|
|
364
|
-
Boolean,
|
|
365
|
-
Array
|
|
366
|
-
],
|
|
367
|
-
required: false,
|
|
368
|
-
default: void 0
|
|
369
|
-
},
|
|
370
|
-
onTransform: {
|
|
371
|
-
type: Function,
|
|
372
|
-
required: false,
|
|
373
|
-
default: void 0
|
|
374
|
-
},
|
|
375
|
-
countRender: {
|
|
376
|
-
type: Function,
|
|
377
|
-
required: false,
|
|
378
|
-
default: void 0
|
|
379
|
-
},
|
|
380
|
-
imageRender: {
|
|
381
|
-
type: Function,
|
|
382
|
-
required: false,
|
|
383
|
-
default: void 0
|
|
384
|
-
},
|
|
385
|
-
actionsRender: {
|
|
386
|
-
type: Function,
|
|
387
|
-
required: false,
|
|
388
|
-
default: void 0
|
|
389
|
-
}
|
|
390
|
-
}, {
|
|
391
|
-
movable: true,
|
|
392
|
-
scaleStep: .5,
|
|
393
|
-
minScale: 1,
|
|
394
|
-
maxScale: 50,
|
|
395
|
-
motionName: "fade",
|
|
396
|
-
current: 0,
|
|
397
|
-
count: 1,
|
|
398
|
-
icons: {}
|
|
399
|
-
}),
|
|
400
|
-
name: "ImagePreview",
|
|
401
|
-
inheritAttrs: false
|
|
402
|
-
});
|
|
403
|
-
var Preview_default = Preview;
|
|
404
|
-
exports.default = Preview_default;
|