@douyinfe/semi-foundation 2.50.0-beta.0 → 2.50.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/previewImageFoundation.ts +5 -3
- package/image/previewInnerFoundation.ts +2 -3
- package/lib/cjs/image/previewImageFoundation.d.ts +1 -1
- package/lib/cjs/image/previewImageFoundation.js +16 -11
- package/lib/cjs/image/previewInnerFoundation.d.ts +1 -1
- package/lib/cjs/image/previewInnerFoundation.js +7 -5
- package/lib/es/image/previewImageFoundation.d.ts +1 -1
- package/lib/es/image/previewImageFoundation.js +16 -11
- package/lib/es/image/previewInnerFoundation.d.ts +1 -1
- package/lib/es/image/previewInnerFoundation.js +7 -5
- package/package.json +3 -3
|
@@ -86,7 +86,9 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
|
|
|
86
86
|
this.setState({
|
|
87
87
|
loading: false,
|
|
88
88
|
} as any);
|
|
89
|
-
|
|
89
|
+
// 图片初次加载,计算 zoom,zoom 改变不需要通过回调透出
|
|
90
|
+
// When the image is loaded for the first time, zoom is calculated, and zoom changes do not need to be exposed through callbacks.
|
|
91
|
+
this.handleResizeImage(false);
|
|
90
92
|
}
|
|
91
93
|
const { src, onLoad } = this.getProps();
|
|
92
94
|
onLoad && onLoad(src);
|
|
@@ -100,7 +102,7 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
|
|
|
100
102
|
onError && onError(src);
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
handleResizeImage = () => {
|
|
105
|
+
handleResizeImage = (notify: boolean = true) => {
|
|
104
106
|
const horizontal = !this._isImageVertical();
|
|
105
107
|
const { currZoom } = this.getStates();
|
|
106
108
|
const imgWidth = horizontal ? this.originImageWidth : this.originImageHeight;
|
|
@@ -120,7 +122,7 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
|
|
|
120
122
|
if (currZoom === _zoom) {
|
|
121
123
|
this.calculatePreviewImage(_zoom, null);
|
|
122
124
|
} else {
|
|
123
|
-
onZoom(_zoom);
|
|
125
|
+
onZoom(_zoom, notify);
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
128
|
}
|
|
@@ -166,7 +166,6 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
|
|
|
166
166
|
direction,
|
|
167
167
|
rotation: 0,
|
|
168
168
|
} as any);
|
|
169
|
-
this._adapter.notifyRotateChange(0);
|
|
170
169
|
}
|
|
171
170
|
|
|
172
171
|
handleDownload = () => {
|
|
@@ -199,10 +198,10 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
|
|
|
199
198
|
this._adapter.notifyRotateChange(newRotation);
|
|
200
199
|
}
|
|
201
200
|
|
|
202
|
-
handleZoomImage = (newZoom: number) => {
|
|
201
|
+
handleZoomImage = (newZoom: number, notify: boolean = true) => {
|
|
203
202
|
const { zoom } = this.getStates();
|
|
204
203
|
if (zoom !== newZoom) {
|
|
205
|
-
this._adapter.notifyZoom(newZoom, newZoom > zoom);
|
|
204
|
+
notify && this._adapter.notifyZoom(newZoom, newZoom > zoom);
|
|
206
205
|
this.setState({
|
|
207
206
|
zoom: newZoom,
|
|
208
207
|
} as any);
|
|
@@ -33,7 +33,7 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
|
|
|
33
33
|
handleWindowResize: () => void;
|
|
34
34
|
handleLoad: (e: any) => void;
|
|
35
35
|
handleError: (e: any) => void;
|
|
36
|
-
handleResizeImage: () => void;
|
|
36
|
+
handleResizeImage: (notify?: boolean) => void;
|
|
37
37
|
handleRatioChange: () => void;
|
|
38
38
|
handleRightClickImage: (e: any) => boolean;
|
|
39
39
|
calcCanDragDirection: () => DragDirection;
|
|
@@ -19,7 +19,9 @@ const DefaultDOMRect = {
|
|
|
19
19
|
};
|
|
20
20
|
class PreviewImageFoundation extends _foundation.default {
|
|
21
21
|
constructor(adapter) {
|
|
22
|
+
var _this;
|
|
22
23
|
super(Object.assign({}, adapter));
|
|
24
|
+
_this = this;
|
|
23
25
|
this.startMouseOffset = {
|
|
24
26
|
x: 0,
|
|
25
27
|
y: 0
|
|
@@ -70,7 +72,9 @@ class PreviewImageFoundation extends _foundation.default {
|
|
|
70
72
|
this.setState({
|
|
71
73
|
loading: false
|
|
72
74
|
});
|
|
73
|
-
|
|
75
|
+
// 图片初次加载,计算 zoom,zoom 改变不需要通过回调透出
|
|
76
|
+
// When the image is loaded for the first time, zoom is calculated, and zoom changes do not need to be exposed through callbacks.
|
|
77
|
+
this.handleResizeImage(false);
|
|
74
78
|
}
|
|
75
79
|
const {
|
|
76
80
|
src,
|
|
@@ -88,24 +92,25 @@ class PreviewImageFoundation extends _foundation.default {
|
|
|
88
92
|
});
|
|
89
93
|
onError && onError(src);
|
|
90
94
|
};
|
|
91
|
-
this.handleResizeImage = ()
|
|
92
|
-
|
|
95
|
+
this.handleResizeImage = function () {
|
|
96
|
+
let notify = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
97
|
+
const horizontal = !_this._isImageVertical();
|
|
93
98
|
const {
|
|
94
99
|
currZoom
|
|
95
|
-
} =
|
|
96
|
-
const imgWidth = horizontal ?
|
|
97
|
-
const imgHeight = horizontal ?
|
|
100
|
+
} = _this.getStates();
|
|
101
|
+
const imgWidth = horizontal ? _this.originImageWidth : _this.originImageHeight;
|
|
102
|
+
const imgHeight = horizontal ? _this.originImageHeight : _this.originImageWidth;
|
|
98
103
|
const {
|
|
99
104
|
onZoom,
|
|
100
105
|
setRatio,
|
|
101
106
|
ratio
|
|
102
|
-
} =
|
|
103
|
-
const containerDOM =
|
|
107
|
+
} = _this.getProps();
|
|
108
|
+
const containerDOM = _this._adapter.getContainer();
|
|
104
109
|
if (containerDOM) {
|
|
105
110
|
const {
|
|
106
111
|
width: containerWidth,
|
|
107
112
|
height: containerHeight
|
|
108
|
-
} =
|
|
113
|
+
} = _this._getContainerBounds();
|
|
109
114
|
const reservedWidth = containerWidth - 80;
|
|
110
115
|
const reservedHeight = containerHeight - 80;
|
|
111
116
|
let _zoom = 1;
|
|
@@ -113,9 +118,9 @@ class PreviewImageFoundation extends _foundation.default {
|
|
|
113
118
|
_zoom = Number(Math.min(reservedWidth / imgWidth, reservedHeight / imgHeight).toFixed(2));
|
|
114
119
|
}
|
|
115
120
|
if (currZoom === _zoom) {
|
|
116
|
-
|
|
121
|
+
_this.calculatePreviewImage(_zoom, null);
|
|
117
122
|
} else {
|
|
118
|
-
onZoom(_zoom);
|
|
123
|
+
onZoom(_zoom, notify);
|
|
119
124
|
}
|
|
120
125
|
}
|
|
121
126
|
};
|
|
@@ -41,7 +41,7 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
|
|
|
41
41
|
handlePreviewClose: () => void;
|
|
42
42
|
handleAdjustRatio: (type: RatioType) => void;
|
|
43
43
|
handleRotateImage: (direction: string) => void;
|
|
44
|
-
handleZoomImage: (newZoom: number) => void;
|
|
44
|
+
handleZoomImage: (newZoom: number, notify?: boolean) => void;
|
|
45
45
|
preloadGapImage: () => void;
|
|
46
46
|
preloadSingleImage: () => void;
|
|
47
47
|
setLoadSuccessStatus: (src: string) => void;
|
|
@@ -15,7 +15,9 @@ const NOT_CLOSE_TARGETS = ["icon", "footer"];
|
|
|
15
15
|
const STOP_CLOSE_TARGET = ["icon", "footer", "header"];
|
|
16
16
|
class PreviewInnerFoundation extends _foundation.default {
|
|
17
17
|
constructor(adapter) {
|
|
18
|
+
var _this;
|
|
18
19
|
super(Object.assign({}, adapter));
|
|
20
|
+
_this = this;
|
|
19
21
|
this._timer = null;
|
|
20
22
|
this._startMouseDown = {
|
|
21
23
|
x: 0,
|
|
@@ -162,7 +164,6 @@ class PreviewInnerFoundation extends _foundation.default {
|
|
|
162
164
|
direction,
|
|
163
165
|
rotation: 0
|
|
164
166
|
});
|
|
165
|
-
this._adapter.notifyRotateChange(0);
|
|
166
167
|
};
|
|
167
168
|
this.handleDownload = () => {
|
|
168
169
|
const {
|
|
@@ -195,13 +196,14 @@ class PreviewInnerFoundation extends _foundation.default {
|
|
|
195
196
|
});
|
|
196
197
|
this._adapter.notifyRotateChange(newRotation);
|
|
197
198
|
};
|
|
198
|
-
this.handleZoomImage = newZoom
|
|
199
|
+
this.handleZoomImage = function (newZoom) {
|
|
200
|
+
let notify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
199
201
|
const {
|
|
200
202
|
zoom
|
|
201
|
-
} =
|
|
203
|
+
} = _this.getStates();
|
|
202
204
|
if (zoom !== newZoom) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
+
notify && _this._adapter.notifyZoom(newZoom, newZoom > zoom);
|
|
206
|
+
_this.setState({
|
|
205
207
|
zoom: newZoom
|
|
206
208
|
});
|
|
207
209
|
}
|
|
@@ -33,7 +33,7 @@ export default class PreviewImageFoundation<P = Record<string, any>, S = Record<
|
|
|
33
33
|
handleWindowResize: () => void;
|
|
34
34
|
handleLoad: (e: any) => void;
|
|
35
35
|
handleError: (e: any) => void;
|
|
36
|
-
handleResizeImage: () => void;
|
|
36
|
+
handleResizeImage: (notify?: boolean) => void;
|
|
37
37
|
handleRatioChange: () => void;
|
|
38
38
|
handleRightClickImage: (e: any) => boolean;
|
|
39
39
|
calcCanDragDirection: () => DragDirection;
|
|
@@ -12,7 +12,9 @@ const DefaultDOMRect = {
|
|
|
12
12
|
};
|
|
13
13
|
export default class PreviewImageFoundation extends BaseFoundation {
|
|
14
14
|
constructor(adapter) {
|
|
15
|
+
var _this;
|
|
15
16
|
super(Object.assign({}, adapter));
|
|
17
|
+
_this = this;
|
|
16
18
|
this.startMouseOffset = {
|
|
17
19
|
x: 0,
|
|
18
20
|
y: 0
|
|
@@ -63,7 +65,9 @@ export default class PreviewImageFoundation extends BaseFoundation {
|
|
|
63
65
|
this.setState({
|
|
64
66
|
loading: false
|
|
65
67
|
});
|
|
66
|
-
|
|
68
|
+
// 图片初次加载,计算 zoom,zoom 改变不需要通过回调透出
|
|
69
|
+
// When the image is loaded for the first time, zoom is calculated, and zoom changes do not need to be exposed through callbacks.
|
|
70
|
+
this.handleResizeImage(false);
|
|
67
71
|
}
|
|
68
72
|
const {
|
|
69
73
|
src,
|
|
@@ -81,24 +85,25 @@ export default class PreviewImageFoundation extends BaseFoundation {
|
|
|
81
85
|
});
|
|
82
86
|
onError && onError(src);
|
|
83
87
|
};
|
|
84
|
-
this.handleResizeImage = ()
|
|
85
|
-
|
|
88
|
+
this.handleResizeImage = function () {
|
|
89
|
+
let notify = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
90
|
+
const horizontal = !_this._isImageVertical();
|
|
86
91
|
const {
|
|
87
92
|
currZoom
|
|
88
|
-
} =
|
|
89
|
-
const imgWidth = horizontal ?
|
|
90
|
-
const imgHeight = horizontal ?
|
|
93
|
+
} = _this.getStates();
|
|
94
|
+
const imgWidth = horizontal ? _this.originImageWidth : _this.originImageHeight;
|
|
95
|
+
const imgHeight = horizontal ? _this.originImageHeight : _this.originImageWidth;
|
|
91
96
|
const {
|
|
92
97
|
onZoom,
|
|
93
98
|
setRatio,
|
|
94
99
|
ratio
|
|
95
|
-
} =
|
|
96
|
-
const containerDOM =
|
|
100
|
+
} = _this.getProps();
|
|
101
|
+
const containerDOM = _this._adapter.getContainer();
|
|
97
102
|
if (containerDOM) {
|
|
98
103
|
const {
|
|
99
104
|
width: containerWidth,
|
|
100
105
|
height: containerHeight
|
|
101
|
-
} =
|
|
106
|
+
} = _this._getContainerBounds();
|
|
102
107
|
const reservedWidth = containerWidth - 80;
|
|
103
108
|
const reservedHeight = containerHeight - 80;
|
|
104
109
|
let _zoom = 1;
|
|
@@ -106,9 +111,9 @@ export default class PreviewImageFoundation extends BaseFoundation {
|
|
|
106
111
|
_zoom = Number(Math.min(reservedWidth / imgWidth, reservedHeight / imgHeight).toFixed(2));
|
|
107
112
|
}
|
|
108
113
|
if (currZoom === _zoom) {
|
|
109
|
-
|
|
114
|
+
_this.calculatePreviewImage(_zoom, null);
|
|
110
115
|
} else {
|
|
111
|
-
onZoom(_zoom);
|
|
116
|
+
onZoom(_zoom, notify);
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
};
|
|
@@ -41,7 +41,7 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
|
|
|
41
41
|
handlePreviewClose: () => void;
|
|
42
42
|
handleAdjustRatio: (type: RatioType) => void;
|
|
43
43
|
handleRotateImage: (direction: string) => void;
|
|
44
|
-
handleZoomImage: (newZoom: number) => void;
|
|
44
|
+
handleZoomImage: (newZoom: number, notify?: boolean) => void;
|
|
45
45
|
preloadGapImage: () => void;
|
|
46
46
|
preloadSingleImage: () => void;
|
|
47
47
|
setLoadSuccessStatus: (src: string) => void;
|
|
@@ -8,7 +8,9 @@ const NOT_CLOSE_TARGETS = ["icon", "footer"];
|
|
|
8
8
|
const STOP_CLOSE_TARGET = ["icon", "footer", "header"];
|
|
9
9
|
export default class PreviewInnerFoundation extends BaseFoundation {
|
|
10
10
|
constructor(adapter) {
|
|
11
|
+
var _this;
|
|
11
12
|
super(Object.assign({}, adapter));
|
|
13
|
+
_this = this;
|
|
12
14
|
this._timer = null;
|
|
13
15
|
this._startMouseDown = {
|
|
14
16
|
x: 0,
|
|
@@ -155,7 +157,6 @@ export default class PreviewInnerFoundation extends BaseFoundation {
|
|
|
155
157
|
direction,
|
|
156
158
|
rotation: 0
|
|
157
159
|
});
|
|
158
|
-
this._adapter.notifyRotateChange(0);
|
|
159
160
|
};
|
|
160
161
|
this.handleDownload = () => {
|
|
161
162
|
const {
|
|
@@ -188,13 +189,14 @@ export default class PreviewInnerFoundation extends BaseFoundation {
|
|
|
188
189
|
});
|
|
189
190
|
this._adapter.notifyRotateChange(newRotation);
|
|
190
191
|
};
|
|
191
|
-
this.handleZoomImage = newZoom
|
|
192
|
+
this.handleZoomImage = function (newZoom) {
|
|
193
|
+
let notify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
192
194
|
const {
|
|
193
195
|
zoom
|
|
194
|
-
} =
|
|
196
|
+
} = _this.getStates();
|
|
195
197
|
if (zoom !== newZoom) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
+
notify && _this._adapter.notifyZoom(newZoom, newZoom > zoom);
|
|
199
|
+
_this.setState({
|
|
198
200
|
zoom: newZoom
|
|
199
201
|
});
|
|
200
202
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.50.0
|
|
3
|
+
"version": "2.50.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build:lib": "node ./scripts/compileLib.js",
|
|
7
7
|
"prepublishOnly": "npm run build:lib"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@douyinfe/semi-animation": "2.50.0
|
|
10
|
+
"@douyinfe/semi-animation": "2.50.0",
|
|
11
11
|
"async-validator": "^3.5.0",
|
|
12
12
|
"classnames": "^2.2.6",
|
|
13
13
|
"date-fns": "^2.29.3",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"*.scss",
|
|
24
24
|
"*.css"
|
|
25
25
|
],
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "4f5ca71f4a992aaadf6c637d8a798ba18c0af740",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
29
29
|
"@babel/preset-env": "^7.15.8",
|