@douyinfe/semi-foundation 2.49.0-beta.0 → 2.49.0
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/image/previewFooterFoundation.ts +1 -4
- package/image/previewImageFoundation.ts +57 -67
- package/image/previewInnerFoundation.ts +73 -30
- package/lib/cjs/image/previewFooterFoundation.d.ts +0 -1
- package/lib/cjs/image/previewFooterFoundation.js +0 -1
- package/lib/cjs/image/previewImageFoundation.d.ts +8 -23
- package/lib/cjs/image/previewImageFoundation.js +66 -80
- package/lib/cjs/image/previewInnerFoundation.d.ts +12 -10
- package/lib/cjs/image/previewInnerFoundation.js +83 -25
- package/lib/cjs/select/foundation.js +1 -1
- package/lib/es/image/previewFooterFoundation.d.ts +0 -1
- package/lib/es/image/previewFooterFoundation.js +0 -1
- package/lib/es/image/previewImageFoundation.d.ts +8 -23
- package/lib/es/image/previewImageFoundation.js +66 -80
- package/lib/es/image/previewInnerFoundation.d.ts +12 -10
- package/lib/es/image/previewInnerFoundation.js +83 -25
- package/lib/es/select/foundation.js +1 -1
- package/package.json +3 -3
- package/select/foundation.ts +1 -1
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from "../base/foundation";
|
|
2
2
|
|
|
3
|
-
export interface PreviewFooterAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S>
|
|
4
|
-
setStartMouseOffset: (time: number) => void
|
|
5
|
-
}
|
|
3
|
+
export interface PreviewFooterAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S>{}
|
|
6
4
|
|
|
7
5
|
export default class PreviewFooterFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<PreviewFooterAdapter<P, S>, P, S> {
|
|
8
6
|
|
|
@@ -24,7 +22,6 @@ export default class PreviewFooterFoundation<P = Record<string, any>, S = Record
|
|
|
24
22
|
} else {
|
|
25
23
|
onZoomOut(Number((value / 100).toFixed(2)));
|
|
26
24
|
}
|
|
27
|
-
this._adapter.setStartMouseOffset(value);
|
|
28
25
|
};
|
|
29
26
|
|
|
30
27
|
handleRatioClick = (): void => {
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from "../base/foundation";
|
|
2
|
-
import { handlePrevent } from "../utils/a11y";
|
|
3
|
-
import { throttle, isUndefined } from "lodash";
|
|
4
2
|
|
|
5
3
|
export interface PreviewImageAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
6
|
-
getOriginImageSize: () => { originImageWidth: number; originImageHeight: number };
|
|
7
|
-
setOriginImageSize: (size: { originImageWidth: number; originImageHeight: number }) => void;
|
|
8
4
|
getContainer: () => HTMLDivElement;
|
|
9
5
|
getImage: () => HTMLImageElement;
|
|
10
|
-
getMouseMove: () => boolean;
|
|
11
|
-
setStartMouseMove: (move: boolean) => void;
|
|
12
|
-
getMouseOffset: () => { x: number; y: number };
|
|
13
|
-
setStartMouseOffset: (offset: { x: number; y: number }) => void;
|
|
14
6
|
setLoading: (loading: boolean) => void;
|
|
15
7
|
setImageCursor: (canDrag: boolean) => void
|
|
16
8
|
}
|
|
@@ -46,6 +38,10 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
|
|
|
46
38
|
super({ ...adapter });
|
|
47
39
|
}
|
|
48
40
|
|
|
41
|
+
startMouseOffset = { x: 0, y: 0 };
|
|
42
|
+
originImageWidth = null;
|
|
43
|
+
originImageHeight = null;
|
|
44
|
+
|
|
49
45
|
_isImageVertical = (): boolean => this.getProp("rotation") % 180 !== 0;
|
|
50
46
|
|
|
51
47
|
_getImageBounds = (): DOMRect => {
|
|
@@ -77,21 +73,16 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
|
|
|
77
73
|
}
|
|
78
74
|
|
|
79
75
|
handleWindowResize = (): void => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (originImageWidth && originImageHeight) {
|
|
83
|
-
if (ratio !== "adaptation") {
|
|
84
|
-
setRatio("adaptation");
|
|
85
|
-
} else {
|
|
86
|
-
this.handleResizeImage();
|
|
87
|
-
}
|
|
76
|
+
if (this.originImageWidth && this.originImageHeight) {
|
|
77
|
+
this.handleResizeImage();
|
|
88
78
|
}
|
|
89
79
|
};
|
|
90
80
|
|
|
91
81
|
handleLoad = (e: any): void => {
|
|
92
82
|
if (e.target) {
|
|
93
|
-
const {
|
|
94
|
-
this.
|
|
83
|
+
const { naturalWidth: w, naturalHeight: h } = e.target as any;
|
|
84
|
+
this.originImageHeight = h;
|
|
85
|
+
this.originImageWidth = w;
|
|
95
86
|
this.setState({
|
|
96
87
|
loading: false,
|
|
97
88
|
} as any);
|
|
@@ -111,19 +102,50 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
|
|
|
111
102
|
|
|
112
103
|
handleResizeImage = () => {
|
|
113
104
|
const horizontal = !this._isImageVertical();
|
|
114
|
-
const {
|
|
115
|
-
const imgWidth = horizontal ? originImageWidth : originImageHeight;
|
|
116
|
-
const imgHeight = horizontal ? originImageHeight : originImageWidth;
|
|
117
|
-
const { onZoom } = this.getProps();
|
|
105
|
+
const { currZoom } = this.getStates();
|
|
106
|
+
const imgWidth = horizontal ? this.originImageWidth : this.originImageHeight;
|
|
107
|
+
const imgHeight = horizontal ? this.originImageHeight : this.originImageWidth;
|
|
108
|
+
const { onZoom, setRatio, ratio } = this.getProps();
|
|
118
109
|
const containerDOM = this._adapter.getContainer();
|
|
119
110
|
if (containerDOM) {
|
|
120
111
|
const { width: containerWidth, height: containerHeight } = this._getContainerBounds();
|
|
121
112
|
const reservedWidth = containerWidth - 80;
|
|
122
113
|
const reservedHeight = containerHeight - 80;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
114
|
+
let _zoom = 1;
|
|
115
|
+
if (imgWidth > reservedWidth || imgHeight > reservedHeight) {
|
|
116
|
+
_zoom = Number(
|
|
117
|
+
Math.min(reservedWidth / imgWidth, reservedHeight / imgHeight).toFixed(2)
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
if (currZoom === _zoom) {
|
|
121
|
+
this.calculatePreviewImage(_zoom, null);
|
|
122
|
+
} else {
|
|
123
|
+
onZoom(_zoom);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
handleRatioChange = () => {
|
|
129
|
+
if (this.originImageWidth && this.originImageHeight) {
|
|
130
|
+
const { currZoom } = this.getStates();
|
|
131
|
+
const { ratio, onZoom } = this.getProps();
|
|
132
|
+
let _zoom: number;
|
|
133
|
+
if (ratio === 'adaptation') {
|
|
134
|
+
const horizontal = !this._isImageVertical();
|
|
135
|
+
const imgWidth = horizontal ? this.originImageWidth : this.originImageHeight;
|
|
136
|
+
const imgHeight = horizontal ? this.originImageHeight : this.originImageWidth;
|
|
137
|
+
const { width: containerWidth, height: containerHeight } = this._getContainerBounds();
|
|
138
|
+
const reservedWidth = containerWidth - 80;
|
|
139
|
+
const reservedHeight = containerHeight - 80;
|
|
140
|
+
_zoom = Number(
|
|
141
|
+
Math.min(reservedWidth / imgWidth, reservedHeight / imgHeight).toFixed(2)
|
|
142
|
+
);
|
|
143
|
+
} else {
|
|
144
|
+
_zoom = 1;
|
|
145
|
+
}
|
|
146
|
+
if (currZoom !== _zoom) {
|
|
147
|
+
onZoom(_zoom);
|
|
148
|
+
}
|
|
127
149
|
}
|
|
128
150
|
}
|
|
129
151
|
|
|
@@ -138,33 +160,6 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
|
|
|
138
160
|
}
|
|
139
161
|
};
|
|
140
162
|
|
|
141
|
-
// e: WheelEvent<HTMLImageElement>
|
|
142
|
-
handleWheel = (e: any) => {
|
|
143
|
-
this.onWheel(e);
|
|
144
|
-
handlePrevent(e);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// e: WheelEvent<HTMLImageElement>
|
|
148
|
-
onWheel = throttle((e: any): void => {
|
|
149
|
-
const { onZoom, zoomStep, maxZoom, minZoom } = this.getProps();
|
|
150
|
-
const { currZoom } = this.getStates();
|
|
151
|
-
let _zoom: number;
|
|
152
|
-
if (e.deltaY < 0) {
|
|
153
|
-
/* zoom in */
|
|
154
|
-
if (currZoom + zoomStep <= maxZoom) {
|
|
155
|
-
_zoom = Number((currZoom + zoomStep).toFixed(2));
|
|
156
|
-
}
|
|
157
|
-
} else if (e.deltaY > 0) {
|
|
158
|
-
/* zoom out */
|
|
159
|
-
if (currZoom - zoomStep >= minZoom) {
|
|
160
|
-
_zoom = Number((currZoom - zoomStep).toFixed(2));
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
if (!isUndefined(_zoom)) {
|
|
164
|
-
onZoom(_zoom);
|
|
165
|
-
}
|
|
166
|
-
}, 50);
|
|
167
|
-
|
|
168
163
|
calcCanDragDirection = (): DragDirection => {
|
|
169
164
|
const { width, height } = this.getStates();
|
|
170
165
|
const { rotation } = this.getProps();
|
|
@@ -181,14 +176,13 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
|
|
|
181
176
|
};
|
|
182
177
|
};
|
|
183
178
|
|
|
184
|
-
|
|
179
|
+
calculatePreviewImage = (newZoom: number, e: any): void => {
|
|
185
180
|
const imageDOM = this._adapter.getImage();
|
|
186
|
-
const { originImageWidth, originImageHeight } = this._adapter.getOriginImageSize();
|
|
187
181
|
const { canDragVertical, canDragHorizontal } = this.calcCanDragDirection();
|
|
188
182
|
const canDrag = canDragVertical || canDragHorizontal;
|
|
189
183
|
const { width: containerWidth, height: containerHeight } = this._getContainerBounds();
|
|
190
|
-
const newWidth = Math.floor(originImageWidth * newZoom);
|
|
191
|
-
const newHeight = Math.floor(originImageHeight * newZoom);
|
|
184
|
+
const newWidth = Math.floor(this.originImageWidth * newZoom);
|
|
185
|
+
const newHeight = Math.floor(this.originImageHeight * newZoom);
|
|
192
186
|
|
|
193
187
|
// debugger;
|
|
194
188
|
let _offset;
|
|
@@ -242,15 +236,15 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
|
|
|
242
236
|
|
|
243
237
|
handleMoveImage = (e: any): void => {
|
|
244
238
|
const { offset, width, height } = this.getStates();
|
|
245
|
-
const startMouseMove = this._adapter.getMouseMove();
|
|
246
|
-
const startMouseOffset = this._adapter.getMouseOffset();
|
|
247
239
|
const { canDragVertical, canDragHorizontal } = this.calcCanDragDirection();
|
|
248
|
-
|
|
240
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
|
|
241
|
+
const mouseLeftPress = e.buttons === 1;
|
|
242
|
+
if (mouseLeftPress && (canDragVertical || canDragHorizontal)) {
|
|
249
243
|
const { clientX, clientY } = e;
|
|
250
244
|
const { left: containerLeft, top: containerTop } = this._getContainerBounds();
|
|
251
245
|
const { left: extremeLeft, top: extremeTop } = this.calcExtremeBounds();
|
|
252
|
-
let newX = canDragHorizontal ? clientX - containerLeft - startMouseOffset.x : offset.x;
|
|
253
|
-
let newY = canDragVertical ? clientY - containerTop - startMouseOffset.y : offset.y;
|
|
246
|
+
let newX = canDragHorizontal ? clientX - containerLeft - this.startMouseOffset.x : offset.x;
|
|
247
|
+
let newY = canDragVertical ? clientY - containerTop - this.startMouseOffset.y : offset.y;
|
|
254
248
|
if (canDragHorizontal) {
|
|
255
249
|
newX = newX > 0 ? 0 : newX < extremeLeft ? extremeLeft : newX;
|
|
256
250
|
}
|
|
@@ -270,11 +264,7 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
|
|
|
270
264
|
};
|
|
271
265
|
|
|
272
266
|
handleImageMouseDown = (e: any): void => {
|
|
273
|
-
this.
|
|
274
|
-
this._adapter.setStartMouseMove(true);
|
|
267
|
+
this.startMouseOffset = this._getOffset(e);
|
|
275
268
|
};
|
|
276
269
|
|
|
277
|
-
handleImageMouseUp = (): void => {
|
|
278
|
-
this._adapter.setStartMouseMove(false);
|
|
279
|
-
};
|
|
280
270
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { handlePrevent } from "../utils/a11y";
|
|
1
2
|
import BaseFoundation, { DefaultAdapter } from "../base/foundation";
|
|
2
3
|
import KeyCode from "../utils/keyCode";
|
|
3
4
|
import { getPreloadImagArr, downloadImage, isTargetEmit } from "./utils";
|
|
5
|
+
import { isUndefined, throttle } from "lodash";
|
|
4
6
|
|
|
5
7
|
export type RatioType = "adaptation" | "realSize";
|
|
6
8
|
export interface PreviewInnerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
@@ -14,15 +16,10 @@ export interface PreviewInnerAdapter<P = Record<string, any>, S = Record<string,
|
|
|
14
16
|
notifyDownload: (src: string, index: number) => void;
|
|
15
17
|
registerKeyDownListener: () => void;
|
|
16
18
|
unregisterKeyDownListener: () => void;
|
|
17
|
-
getMouseActiveTime: () => number;
|
|
18
|
-
getStopTiming: () => boolean;
|
|
19
|
-
setStopTiming: (value: boolean) => void;
|
|
20
|
-
getStartMouseDown: () => {x: number; y: number};
|
|
21
|
-
setStartMouseDown: (x: number, y: number) => void;
|
|
22
|
-
setMouseActiveTime: (time: number) => void;
|
|
23
19
|
disabledBodyScroll: () => void;
|
|
24
20
|
enabledBodyScroll: () => void;
|
|
25
|
-
getSetDownloadFunc: () => (src: string) => string
|
|
21
|
+
getSetDownloadFunc: () => (src: string) => string;
|
|
22
|
+
isValidTarget: (e: any) => boolean
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
|
|
@@ -34,50 +31,94 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
|
|
|
34
31
|
super({ ...adapter });
|
|
35
32
|
}
|
|
36
33
|
|
|
34
|
+
_timer = null;
|
|
35
|
+
_startMouseDown = { x: 0, y: 0 };
|
|
36
|
+
|
|
37
37
|
beforeShow() {
|
|
38
38
|
this._adapter.registerKeyDownListener();
|
|
39
39
|
this._adapter.disabledBodyScroll();
|
|
40
|
+
this.updateTimer();
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
afterHide() {
|
|
43
44
|
this._adapter.unregisterKeyDownListener();
|
|
44
45
|
this._adapter.enabledBodyScroll();
|
|
46
|
+
this.clearTimer();
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
handleViewVisibleChange = () => {
|
|
48
|
-
const nowTime = new Date().getTime();
|
|
49
|
-
const mouseActiveTime = this._adapter.getMouseActiveTime();
|
|
50
|
-
const stopTiming = this._adapter.getStopTiming();
|
|
51
|
-
const { viewerVisibleDelay } = this.getProps();
|
|
52
50
|
const { viewerVisible } = this.getStates();
|
|
53
|
-
if (
|
|
54
|
-
|
|
51
|
+
if (viewerVisible) {
|
|
52
|
+
this.setState({
|
|
55
53
|
viewerVisible: false,
|
|
56
54
|
} as any);
|
|
55
|
+
this.clearTimer();
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
handleMouseMove = (e) => {
|
|
60
|
+
this._persistEvent(e);
|
|
61
|
+
this.mouseMoveHandler(e);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
mouseMoveHandler = throttle((e: any) => {
|
|
65
|
+
const { viewerVisible } = this.getStates();
|
|
66
|
+
const isValidTarget = this._adapter.isValidTarget(e);
|
|
67
|
+
if (isValidTarget) {
|
|
68
|
+
if (!viewerVisible) {
|
|
69
|
+
this.setState({
|
|
70
|
+
viewerVisible: true,
|
|
71
|
+
} as any);
|
|
72
|
+
}
|
|
73
|
+
this.updateTimer();
|
|
74
|
+
} else {
|
|
75
|
+
this.clearTimer();
|
|
66
76
|
}
|
|
77
|
+
}, 50);
|
|
78
|
+
|
|
79
|
+
updateTimer = () => {
|
|
80
|
+
const { viewerVisibleDelay } = this.getProps();
|
|
81
|
+
this.clearTimer();
|
|
82
|
+
this._timer = setTimeout(this.handleViewVisibleChange, viewerVisibleDelay);
|
|
67
83
|
}
|
|
68
84
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
85
|
+
clearTimer = () => {
|
|
86
|
+
if (this._timer) {
|
|
87
|
+
clearTimeout(this._timer);
|
|
88
|
+
this._timer = null;
|
|
89
|
+
}
|
|
74
90
|
}
|
|
75
91
|
|
|
92
|
+
handleWheel = (e: any) => {
|
|
93
|
+
this.onWheel(e);
|
|
94
|
+
handlePrevent(e);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
onWheel = (e: any): void => {
|
|
98
|
+
const { zoomStep, maxZoom, minZoom } = this.getProps();
|
|
99
|
+
const { zoom: currZoom } = this.getStates();
|
|
100
|
+
let _zoom: number;
|
|
101
|
+
if (e.deltaY < 0) {
|
|
102
|
+
/* zoom in */
|
|
103
|
+
if (currZoom + zoomStep <= maxZoom) {
|
|
104
|
+
_zoom = Number((currZoom + zoomStep).toFixed(2));
|
|
105
|
+
}
|
|
106
|
+
} else if (e.deltaY > 0) {
|
|
107
|
+
/* zoom out */
|
|
108
|
+
if (currZoom - zoomStep >= minZoom) {
|
|
109
|
+
_zoom = Number((currZoom - zoomStep).toFixed(2));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (!isUndefined(_zoom)) {
|
|
113
|
+
this.handleZoomImage(_zoom);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
76
117
|
handleMouseUp = (e: any) => {
|
|
77
118
|
const { maskClosable } = this.getProps();
|
|
78
119
|
let couldClose = !isTargetEmit(e, NOT_CLOSE_TARGETS);
|
|
79
120
|
const { clientX, clientY } = e;
|
|
80
|
-
const { x, y } = this.
|
|
121
|
+
const { x, y } = this._startMouseDown;
|
|
81
122
|
// 对鼠标移动做容错处理,当 x 和 y 方向在 mouseUp 的时候移动距离都小于等于 5px 时候就可以关闭预览
|
|
82
123
|
// Error-tolerant processing of mouse movement, when the movement distance in the x and y directions is less than or equal to 5px in mouseUp, the preview can be closed
|
|
83
124
|
// 不做容错处理的话,直接用 clientX !== x || y !== clientY 做判断,鼠标在用户点击时候无意识的轻微移动无法关闭预览,不符合用户预期
|
|
@@ -92,7 +133,7 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
|
|
|
92
133
|
|
|
93
134
|
handleMouseDown = (e: any) => {
|
|
94
135
|
const { clientX, clientY } = e;
|
|
95
|
-
this.
|
|
136
|
+
this._startMouseDown = { x: clientX, y: clientY } ;
|
|
96
137
|
}
|
|
97
138
|
|
|
98
139
|
handleKeyDown = (e: any) => {
|
|
@@ -160,10 +201,12 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
|
|
|
160
201
|
|
|
161
202
|
handleZoomImage = (newZoom: number) => {
|
|
162
203
|
const { zoom } = this.getStates();
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
204
|
+
if (zoom !== newZoom) {
|
|
205
|
+
this._adapter.notifyZoom(newZoom, newZoom > zoom);
|
|
206
|
+
this.setState({
|
|
207
|
+
zoom: newZoom,
|
|
208
|
+
} as any);
|
|
209
|
+
}
|
|
167
210
|
}
|
|
168
211
|
|
|
169
212
|
// 当 visible 改变之后,预览组件完成首张图片加载后,启动预加载
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from "../base/foundation";
|
|
2
2
|
export interface PreviewFooterAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
3
|
-
setStartMouseOffset: (time: number) => void;
|
|
4
3
|
}
|
|
5
4
|
export default class PreviewFooterFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<PreviewFooterAdapter<P, S>, P, S> {
|
|
6
5
|
changeSliderValue: (type: string) => void;
|
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
/// <reference types="lodash" />
|
|
2
1
|
import BaseFoundation, { DefaultAdapter } from "../base/foundation";
|
|
3
2
|
export interface PreviewImageAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
4
|
-
getOriginImageSize: () => {
|
|
5
|
-
originImageWidth: number;
|
|
6
|
-
originImageHeight: number;
|
|
7
|
-
};
|
|
8
|
-
setOriginImageSize: (size: {
|
|
9
|
-
originImageWidth: number;
|
|
10
|
-
originImageHeight: number;
|
|
11
|
-
}) => void;
|
|
12
3
|
getContainer: () => HTMLDivElement;
|
|
13
4
|
getImage: () => HTMLImageElement;
|
|
14
|
-
getMouseMove: () => boolean;
|
|
15
|
-
setStartMouseMove: (move: boolean) => void;
|
|
16
|
-
getMouseOffset: () => {
|
|
17
|
-
x: number;
|
|
18
|
-
y: number;
|
|
19
|
-
};
|
|
20
|
-
setStartMouseOffset: (offset: {
|
|
21
|
-
x: number;
|
|
22
|
-
y: number;
|
|
23
|
-
}) => void;
|
|
24
5
|
setLoading: (loading: boolean) => void;
|
|
25
6
|
setImageCursor: (canDrag: boolean) => void;
|
|
26
7
|
}
|
|
@@ -38,6 +19,12 @@ export interface ImageOffset {
|
|
|
38
19
|
}
|
|
39
20
|
export default class PreviewImageFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<PreviewImageAdapter<P, S>, P, S> {
|
|
40
21
|
constructor(adapter: PreviewImageAdapter<P, S>);
|
|
22
|
+
startMouseOffset: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
};
|
|
26
|
+
originImageWidth: any;
|
|
27
|
+
originImageHeight: any;
|
|
41
28
|
_isImageVertical: () => boolean;
|
|
42
29
|
_getImageBounds: () => DOMRect;
|
|
43
30
|
_getContainerBounds: () => DOMRect;
|
|
@@ -47,13 +34,11 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
|
|
|
47
34
|
handleLoad: (e: any) => void;
|
|
48
35
|
handleError: (e: any) => void;
|
|
49
36
|
handleResizeImage: () => void;
|
|
37
|
+
handleRatioChange: () => void;
|
|
50
38
|
handleRightClickImage: (e: any) => boolean;
|
|
51
|
-
handleWheel: (e: any) => void;
|
|
52
|
-
onWheel: import("lodash").DebouncedFunc<(e: any) => void>;
|
|
53
39
|
calcCanDragDirection: () => DragDirection;
|
|
54
|
-
|
|
40
|
+
calculatePreviewImage: (newZoom: number, e: any) => void;
|
|
55
41
|
calcExtremeBounds: () => ExtremeBounds;
|
|
56
42
|
handleMoveImage: (e: any) => void;
|
|
57
43
|
handleImageMouseDown: (e: any) => void;
|
|
58
|
-
handleImageMouseUp: () => void;
|
|
59
44
|
}
|