bhd-components 0.9.17 → 0.9.19

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.
Files changed (35) hide show
  1. package/dist/index.esm.es5.development.css +1265 -1221
  2. package/dist/index.esm.es5.development.js +109 -62
  3. package/dist/index.esm.es5.production.css +1 -1
  4. package/dist/index.esm.es5.production.js +1 -1
  5. package/dist/vendor.esm.es5.development.js +1 -1
  6. package/dist/vendor.esm.es5.production.js +1 -1
  7. package/es2017/customerService/index.module.less +15 -4
  8. package/es2017/customerService/index2.module.less +14 -4
  9. package/es2017/icons/components/custom-screen-xuanzuan.d.ts +4 -0
  10. package/es2017/icons/components/custom-screen-xuanzuan.js +28 -0
  11. package/es2017/icons/components/custom-xuanzuan.js +16 -14
  12. package/es2017/icons/components/index.d.ts +1 -0
  13. package/es2017/icons/components/index.js +1 -0
  14. package/es2017/table/index.module.less +22 -14
  15. package/es2017/viewImage/index(/345/216/237).d.ts +31 -0
  16. package/es2017/viewImage/index(/345/216/237).js +384 -0
  17. package/es2017/viewImage/index.d.ts +1 -0
  18. package/es2017/viewImage/index.js +90 -45
  19. package/es2017/viewImage/index.module(/345/216/237).less +173 -0
  20. package/es2017/viewImage/index.module.less +29 -9
  21. package/esm/customerService/index.module.less +15 -4
  22. package/esm/customerService/index2.module.less +14 -4
  23. package/esm/icons/components/custom-screen-xuanzuan.d.ts +4 -0
  24. package/esm/icons/components/custom-screen-xuanzuan.js +30 -0
  25. package/esm/icons/components/custom-xuanzuan.js +16 -14
  26. package/esm/icons/components/index.d.ts +1 -0
  27. package/esm/icons/components/index.js +1 -0
  28. package/esm/table/index.module.less +22 -14
  29. package/esm/viewImage/index(/345/216/237).d.ts +31 -0
  30. package/esm/viewImage/index(/345/216/237).js +480 -0
  31. package/esm/viewImage/index.d.ts +1 -0
  32. package/esm/viewImage/index.js +90 -45
  33. package/esm/viewImage/index.module(/345/216/237).less +173 -0
  34. package/esm/viewImage/index.module.less +29 -9
  35. package/package.json +1 -1
@@ -0,0 +1,384 @@
1
+ import { _ as _define_property } from "@swc/helpers/_/_define_property";
2
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
+ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
5
+ import * as React from "react";
6
+ import { useRef, useImperativeHandle, forwardRef } from "react";
7
+ import styles from "./index.module.less";
8
+ import { Modal } from "antd";
9
+ import { LeftOutlined, RightOutlined, MinusOutlined, PlusOutlined, CustomClose, CustomXuanZuan, CustomDownLoad } from "../icons";
10
+ import { getStyle } from "../utils/dom";
11
+ import { Loading } from "../images";
12
+ import BhdTipModal from "../bhdTipModal";
13
+ class ViewImage extends React.Component {
14
+ componentDidMount() {
15
+ this.setState({
16
+ multiSelect: !!this.props.multiSelect || false
17
+ }, ()=>{
18
+ if (!this.state.multiSelect) {
19
+ this.getSrc();
20
+ } else {
21
+ //多张
22
+ this.getSrc(0);
23
+ }
24
+ });
25
+ document.oncontextmenu = function() {
26
+ return false;
27
+ };
28
+ }
29
+ componentWillUnmount() {
30
+ document.oncontextmenu = null;
31
+ }
32
+ render() {
33
+ let { scaleValue, imgSrc, imgLeft, imgTop, rotateValue, loading, multiSelect, imgError } = this.state;
34
+ let { content, download } = this.props;
35
+ return /*#__PURE__*/ _jsxs("div", {
36
+ className: styles.viewImgBody,
37
+ children: [
38
+ /*#__PURE__*/ _jsxs("div", {
39
+ className: styles.viewImgContent,
40
+ children: [
41
+ /*#__PURE__*/ _jsxs("div", {
42
+ className: styles.viewImgAction,
43
+ children: [
44
+ /*#__PURE__*/ _jsx("span", {
45
+ title: "旋转",
46
+ onClick: this.rotate,
47
+ children: /*#__PURE__*/ _jsx(CustomXuanZuan, {})
48
+ }),
49
+ download && !imgError && /*#__PURE__*/ _jsx("span", {
50
+ title: "下载",
51
+ onClick: this.downloadUrl,
52
+ children: /*#__PURE__*/ _jsx(CustomDownLoad, {})
53
+ }),
54
+ /*#__PURE__*/ _jsx("span", {
55
+ title: "关闭",
56
+ onClick: this.close,
57
+ children: /*#__PURE__*/ _jsx(CustomClose, {})
58
+ })
59
+ ]
60
+ }),
61
+ /*#__PURE__*/ _jsxs("div", {
62
+ className: styles.viewImgBody,
63
+ children: [
64
+ loading ? /*#__PURE__*/ _jsx("img", {
65
+ src: Loading,
66
+ className: styles.viewImgBody_load
67
+ }, "load") : imgError ? /*#__PURE__*/ _jsx("div", {
68
+ style: {
69
+ color: "#FFFFFF"
70
+ },
71
+ children: imgSrc ? "图片加载错误" : "暂无内容"
72
+ }) : /*#__PURE__*/ _jsx("img", {
73
+ src: imgSrc,
74
+ alt: "图片加载错误",
75
+ draggable: "false",
76
+ onMouseDown: this.moveImg,
77
+ style: {
78
+ transform: `scale(${scaleValue / 100},${scaleValue / 100}) rotate(${rotateValue}deg)`,
79
+ left: imgLeft == "auto" ? "auto" : imgLeft + "px",
80
+ top: imgTop == "auto" ? "auto" : imgTop + "px"
81
+ },
82
+ className: styles.viewImgBody_pic,
83
+ onLoad: this.imgLoad,
84
+ onError: this.imgErr
85
+ }, "img"),
86
+ multiSelect && /*#__PURE__*/ _jsxs(_Fragment, {
87
+ children: [
88
+ this.state.curIndex !== 0 && /*#__PURE__*/ _jsx("div", {
89
+ className: styles.viewImgBody_pre,
90
+ onClick: this.preChange,
91
+ children: /*#__PURE__*/ _jsx(LeftOutlined, {})
92
+ }),
93
+ this.state.curIndex < this.props.multiSelect.length - 1 && /*#__PURE__*/ _jsx("div", {
94
+ className: styles.viewImgBody_next,
95
+ onClick: this.nextChange,
96
+ children: /*#__PURE__*/ _jsx(RightOutlined, {})
97
+ })
98
+ ]
99
+ })
100
+ ]
101
+ }),
102
+ /*#__PURE__*/ _jsxs("div", {
103
+ className: styles.viewImgBodyScale,
104
+ children: [
105
+ /*#__PURE__*/ _jsx("span", {
106
+ className: styles.viewImgBodyScale_minu,
107
+ onClick: ()=>{
108
+ scaleValue = scaleValue - 10;
109
+ this.scaleChange(scaleValue);
110
+ },
111
+ children: /*#__PURE__*/ _jsx(MinusOutlined, {})
112
+ }),
113
+ /*#__PURE__*/ _jsxs("span", {
114
+ className: styles.viewImgBodyScale_value,
115
+ onClick: this.reset,
116
+ children: [
117
+ scaleValue,
118
+ "%"
119
+ ]
120
+ }),
121
+ /*#__PURE__*/ _jsx("span", {
122
+ className: styles.viewImgBodyScale_add,
123
+ onClick: ()=>{
124
+ scaleValue = scaleValue + 10;
125
+ this.scaleChange(scaleValue);
126
+ },
127
+ children: /*#__PURE__*/ _jsx(PlusOutlined, {})
128
+ })
129
+ ]
130
+ })
131
+ ]
132
+ }),
133
+ content && /*#__PURE__*/ _jsx("div", {
134
+ className: styles.viewImgInfo,
135
+ children: content()
136
+ })
137
+ ]
138
+ });
139
+ }
140
+ constructor(...args){
141
+ super(...args);
142
+ _define_property(this, "state", {
143
+ scaleValue: 100,
144
+ maxScale: 500,
145
+ minScale: 1,
146
+ imgSrc: "",
147
+ imgLeft: "auto",
148
+ imgTop: "auto",
149
+ rotateValue: 0,
150
+ loading: false,
151
+ curIndex: 0,
152
+ multiSelect: false,
153
+ imgError: false
154
+ });
155
+ _define_property(this, "scaleChange", (value)=>{
156
+ let { maxScale, minScale } = this.state;
157
+ if (value >= maxScale) {
158
+ value = maxScale;
159
+ }
160
+ if (value <= minScale) {
161
+ value = minScale;
162
+ }
163
+ this.setState({
164
+ scaleValue: value
165
+ });
166
+ });
167
+ _define_property(this, "moveImg", (ev)=>{
168
+ let { imgLeft, imgTop } = this.state;
169
+ ev.preventDefault();
170
+ let dom = document.getElementsByClassName(`${styles.viewImgBody_pic}`)[0];
171
+ if (!dom) return;
172
+ if (imgLeft == "auto") {
173
+ imgLeft = getStyle(dom, "left");
174
+ }
175
+ if (imgTop == "auto") {
176
+ imgTop = getStyle(dom, "top");
177
+ }
178
+ var disx = ev.pageX - imgLeft;
179
+ var disy = ev.pageY - imgTop;
180
+ const mouseMove = (ev)=>{
181
+ this.setState({
182
+ imgLeft: ev.pageX - disx,
183
+ imgTop: ev.pageY - disy
184
+ }, ()=>{});
185
+ };
186
+ const mouseUp = ()=>{
187
+ document.removeEventListener("mousemove", mouseMove);
188
+ document.removeEventListener("mouseup", mouseUp);
189
+ };
190
+ document.addEventListener("mousemove", mouseMove);
191
+ document.addEventListener("mouseup", mouseUp);
192
+ });
193
+ _define_property(this, "base64Down", (src)=>{
194
+ let { filename } = this.props;
195
+ var base64 = src.toString(); // imgSrc 就是base64哈
196
+ let type = "png";
197
+ var byteCharacters = atob(base64.replace(/^data:image\/(png|jpeg|jpg);base64,/, (a, b)=>{
198
+ type = b;
199
+ return "";
200
+ }));
201
+ var byteNumbers = new Array(byteCharacters.length);
202
+ for(var i = 0; i < byteCharacters.length; i++){
203
+ byteNumbers[i] = byteCharacters.charCodeAt(i);
204
+ }
205
+ var byteArray = new Uint8Array(byteNumbers);
206
+ var blob = new Blob([
207
+ byteArray
208
+ ], {
209
+ type: undefined
210
+ });
211
+ var aLink = document.createElement("a");
212
+ aLink.download = `${filename || "download"}.${type}`; //这里写保存时的图片名称
213
+ let blobUrl = URL.createObjectURL(blob);
214
+ aLink.href = blobUrl;
215
+ aLink.click();
216
+ URL.revokeObjectURL(blobUrl);
217
+ });
218
+ _define_property(this, "downloadUrl", ()=>{
219
+ let { imgSrc } = this.state;
220
+ if (/^data:/.test(imgSrc)) {
221
+ try {
222
+ this.base64Down(imgSrc);
223
+ } catch (error) {
224
+ BhdTipModal.confirm({
225
+ title: "提示信息",
226
+ centered: true,
227
+ content: "图片资源不支持下载",
228
+ cancelBtn: false
229
+ });
230
+ }
231
+ } else if (/^(https?:\/\/[^\s]+)/.test(imgSrc)) {
232
+ //在线url
233
+ try {
234
+ this.downloadFile(imgSrc);
235
+ } catch (error) {
236
+ BhdTipModal.confirm({
237
+ title: "提示信息",
238
+ centered: true,
239
+ content: "图片资源不支持下载",
240
+ cancelBtn: false
241
+ });
242
+ }
243
+ } else {
244
+ //不支持下载
245
+ BhdTipModal.confirm({
246
+ title: "提示信息",
247
+ centered: true,
248
+ content: "图片资源不支持下载",
249
+ cancelBtn: false
250
+ });
251
+ }
252
+ });
253
+ _define_property(this, "downloadFile", (url, headers, callback = ()=>{})=>{
254
+ let { filename } = this.props;
255
+ let suffix = "png";
256
+ var xhr = new XMLHttpRequest();
257
+ if (url.indexOf("?") != -1) {
258
+ url = url + "&down_t=" + new Date().valueOf();
259
+ } else {
260
+ url = url + "?down_t=" + new Date().valueOf();
261
+ }
262
+ xhr.open("GET", url, true);
263
+ for(let key in headers){
264
+ xhr.setRequestHeader(key, headers[key]);
265
+ }
266
+ xhr.responseType = "blob";
267
+ //关键部分
268
+ xhr.onload = function(e) {
269
+ //如果请求执行成功
270
+ if (this.status == 200) {
271
+ var blob = this.response;
272
+ var a = document.createElement("a");
273
+ if (this.response.type) {
274
+ try {
275
+ suffix = this.response.type.replace("image/", "");
276
+ } catch (error) {
277
+ suffix = "png";
278
+ console.error(error);
279
+ }
280
+ }
281
+ //创键临时url对象
282
+ var url = URL.createObjectURL(blob);
283
+ a.href = url;
284
+ a.download = `${filename || "download"}.${suffix}`;
285
+ a.click();
286
+ //释放之前创建的URL对象
287
+ window.URL.revokeObjectURL(url);
288
+ typeof callback == "function" && callback();
289
+ }
290
+ };
291
+ xhr.onerror = function() {
292
+ BhdTipModal.confirm({
293
+ title: "提示信息",
294
+ centered: true,
295
+ content: "图片资源不支持下载",
296
+ cancelBtn: false
297
+ });
298
+ };
299
+ //发送请求
300
+ xhr.send();
301
+ });
302
+ _define_property(this, "reset", ()=>{
303
+ this.setState({
304
+ imgLeft: "auto",
305
+ imgTop: "auto",
306
+ rotateValue: 0,
307
+ scaleValue: 100
308
+ });
309
+ });
310
+ _define_property(this, "rotate", ()=>{
311
+ this.setState({
312
+ rotateValue: this.state.rotateValue + 90
313
+ });
314
+ });
315
+ _define_property(this, "close", ()=>{
316
+ this.props.onCancel();
317
+ });
318
+ //获取图片
319
+ _define_property(this, "getSrc", async (curIndex)=>{
320
+ this.setState({
321
+ loading: true,
322
+ curIndex
323
+ });
324
+ let src;
325
+ if (this.state.multiSelect) {
326
+ src = await this.props.getSrc(curIndex);
327
+ } else {
328
+ src = await this.props.getSrc();
329
+ }
330
+ this.setState({
331
+ imgSrc: src,
332
+ loading: false
333
+ });
334
+ });
335
+ _define_property(this, "preChange", async ()=>{
336
+ let { curIndex } = this.state;
337
+ if (curIndex == 0) return;
338
+ await this.getSrc(curIndex - 1);
339
+ });
340
+ _define_property(this, "nextChange", async ()=>{
341
+ let { curIndex } = this.state;
342
+ if (curIndex == this.props.multiSelect.length - 1) return;
343
+ await this.getSrc(curIndex + 1);
344
+ });
345
+ _define_property(this, "imgLoad", ()=>{
346
+ this.setState({
347
+ imgError: false
348
+ });
349
+ });
350
+ _define_property(this, "imgErr", ()=>{
351
+ this.setState({
352
+ imgError: true
353
+ });
354
+ });
355
+ }
356
+ }
357
+ const AppViewImage = /*#__PURE__*/ forwardRef((props, ref)=>{
358
+ let { visible, className } = props;
359
+ const viewRef = useRef(null);
360
+ useImperativeHandle(ref, ()=>({
361
+ updateSrc: ()=>{
362
+ viewRef.current.getSrc();
363
+ }
364
+ }));
365
+ return /*#__PURE__*/ _jsx(Modal, {
366
+ transitionName: "",
367
+ maskTransitionName: "",
368
+ title: null,
369
+ footer: null,
370
+ closable: false,
371
+ centered: true,
372
+ // destroyOnClose
373
+ open: visible,
374
+ keyboard: false,
375
+ maskStyle: {
376
+ background: "rgba(0, 0, 0, 0.65)"
377
+ },
378
+ wrapClassName: `${styles.AppViewImage} ${className || ""}`,
379
+ children: visible && /*#__PURE__*/ _jsx(ViewImage, _object_spread_props(_object_spread({}, props), {
380
+ ref: viewRef
381
+ }))
382
+ });
383
+ });
384
+ export default AppViewImage;
@@ -24,6 +24,7 @@ export interface ViewImageState {
24
24
  curIndex: number;
25
25
  imgError: boolean;
26
26
  multiSelect: boolean;
27
+ actionCloseFlag: number;
27
28
  }
28
29
  export interface ViewImageProps extends AppViewImageProps {
29
30
  }
@@ -6,7 +6,7 @@ import * as React from "react";
6
6
  import { useRef, useImperativeHandle, forwardRef } from "react";
7
7
  import styles from "./index.module.less";
8
8
  import { Modal } from "antd";
9
- import { LeftOutlined, RightOutlined, MinusOutlined, PlusOutlined, CustomClose, CustomXuanZuan, CustomDownLoad } from "../icons";
9
+ import { LeftOutlined, RightOutlined, MinusOutlined, PlusOutlined, CustomClose, CustomScreenXuanZuan, CustomDownLoad } from "../icons";
10
10
  import { getStyle } from "../utils/dom";
11
11
  import { Loading } from "../images";
12
12
  import BhdTipModal from "../bhdTipModal";
@@ -38,23 +38,58 @@ class ViewImage extends React.Component {
38
38
  /*#__PURE__*/ _jsxs("div", {
39
39
  className: styles.viewImgContent,
40
40
  children: [
41
+ this.state.actionCloseFlag === 1 && /*#__PURE__*/ _jsx("div", {
42
+ className: `${styles.viewImgAction} ${styles.actionTop}`,
43
+ children: /*#__PURE__*/ _jsx("span", {
44
+ // id="actionClose"
45
+ // style={{right:`calc(-40px + (-12px * (1 / ${scaleValue / 100}) ))` ,transform: `scale(calc(1 / ${scaleValue / 100}),calc(1 / ${scaleValue / 100}))`,transformOrigin: `top left`}}
46
+ className: styles.viewImgActionClose,
47
+ title: "关闭",
48
+ onClick: this.close,
49
+ children: /*#__PURE__*/ _jsx(CustomClose, {})
50
+ })
51
+ }),
41
52
  /*#__PURE__*/ _jsxs("div", {
42
53
  className: styles.viewImgAction,
43
54
  children: [
44
55
  /*#__PURE__*/ _jsx("span", {
45
56
  title: "旋转",
46
57
  onClick: this.rotate,
47
- children: /*#__PURE__*/ _jsx(CustomXuanZuan, {})
58
+ children: /*#__PURE__*/ _jsx(CustomScreenXuanZuan, {})
48
59
  }),
49
60
  download && !imgError && /*#__PURE__*/ _jsx("span", {
50
61
  title: "下载",
51
62
  onClick: this.downloadUrl,
52
63
  children: /*#__PURE__*/ _jsx(CustomDownLoad, {})
53
64
  }),
54
- /*#__PURE__*/ _jsx("span", {
55
- title: "关闭",
56
- onClick: this.close,
57
- children: /*#__PURE__*/ _jsx(CustomClose, {})
65
+ /*#__PURE__*/ _jsxs("div", {
66
+ className: styles.viewImgBodyScale,
67
+ children: [
68
+ /*#__PURE__*/ _jsx("span", {
69
+ className: styles.viewImgBodyScale_minu,
70
+ onClick: ()=>{
71
+ scaleValue = scaleValue - 10;
72
+ this.scaleChange(scaleValue);
73
+ },
74
+ children: /*#__PURE__*/ _jsx(MinusOutlined, {})
75
+ }),
76
+ /*#__PURE__*/ _jsxs("span", {
77
+ className: styles.viewImgBodyScale_value,
78
+ onClick: this.reset,
79
+ children: [
80
+ scaleValue,
81
+ "%"
82
+ ]
83
+ }),
84
+ /*#__PURE__*/ _jsx("span", {
85
+ className: styles.viewImgBodyScale_add,
86
+ onClick: ()=>{
87
+ scaleValue = scaleValue + 10;
88
+ this.scaleChange(scaleValue);
89
+ },
90
+ children: /*#__PURE__*/ _jsx(PlusOutlined, {})
91
+ })
92
+ ]
58
93
  })
59
94
  ]
60
95
  }),
@@ -69,20 +104,40 @@ class ViewImage extends React.Component {
69
104
  color: "#FFFFFF"
70
105
  },
71
106
  children: imgSrc ? "图片加载错误" : "暂无内容"
72
- }) : /*#__PURE__*/ _jsx("img", {
73
- src: imgSrc,
74
- alt: "图片加载错误",
75
- draggable: "false",
107
+ }) : /*#__PURE__*/ _jsxs("div", {
76
108
  onMouseDown: this.moveImg,
77
109
  style: {
78
- transform: `scale(${scaleValue / 100},${scaleValue / 100}) rotate(${rotateValue}deg)`,
110
+ transform: `scale(${scaleValue / 100},${scaleValue / 100})`,
79
111
  left: imgLeft == "auto" ? "auto" : imgLeft + "px",
80
112
  top: imgTop == "auto" ? "auto" : imgTop + "px"
81
113
  },
82
114
  className: styles.viewImgBody_pic,
83
- onLoad: this.imgLoad,
84
- onError: this.imgErr
85
- }, "img"),
115
+ children: [
116
+ /*#__PURE__*/ _jsx("img", {
117
+ id: "viewImgBody_pic",
118
+ src: imgSrc,
119
+ alt: "图片加载错误",
120
+ draggable: "false",
121
+ style: {
122
+ transform: `rotate(${rotateValue}deg)`
123
+ },
124
+ onLoad: this.imgLoad,
125
+ onError: this.imgErr
126
+ }, "img"),
127
+ this.state.actionCloseFlag === 0 && /*#__PURE__*/ _jsx("span", {
128
+ id: "actionClose",
129
+ style: {
130
+ right: `calc(-40px + (-12px * (1 / ${scaleValue / 100}) ))`,
131
+ transform: `scale(calc(1 / ${scaleValue / 100}),calc(1 / ${scaleValue / 100}))`,
132
+ transformOrigin: `top left`
133
+ },
134
+ className: styles.viewImgActionClose,
135
+ title: "关闭",
136
+ onClick: this.close,
137
+ children: /*#__PURE__*/ _jsx(CustomClose, {})
138
+ })
139
+ ]
140
+ }),
86
141
  multiSelect && /*#__PURE__*/ _jsxs(_Fragment, {
87
142
  children: [
88
143
  this.state.curIndex !== 0 && /*#__PURE__*/ _jsx("div", {
@@ -98,35 +153,6 @@ class ViewImage extends React.Component {
98
153
  ]
99
154
  })
100
155
  ]
101
- }),
102
- /*#__PURE__*/ _jsxs("div", {
103
- className: styles.viewImgBodyScale,
104
- children: [
105
- /*#__PURE__*/ _jsx("span", {
106
- className: styles.viewImgBodyScale_minu,
107
- onClick: ()=>{
108
- scaleValue = scaleValue - 10;
109
- this.scaleChange(scaleValue);
110
- },
111
- children: /*#__PURE__*/ _jsx(MinusOutlined, {})
112
- }),
113
- /*#__PURE__*/ _jsxs("span", {
114
- className: styles.viewImgBodyScale_value,
115
- onClick: this.reset,
116
- children: [
117
- scaleValue,
118
- "%"
119
- ]
120
- }),
121
- /*#__PURE__*/ _jsx("span", {
122
- className: styles.viewImgBodyScale_add,
123
- onClick: ()=>{
124
- scaleValue = scaleValue + 10;
125
- this.scaleChange(scaleValue);
126
- },
127
- children: /*#__PURE__*/ _jsx(PlusOutlined, {})
128
- })
129
- ]
130
156
  })
131
157
  ]
132
158
  }),
@@ -150,7 +176,8 @@ class ViewImage extends React.Component {
150
176
  loading: false,
151
177
  curIndex: 0,
152
178
  multiSelect: false,
153
- imgError: false
179
+ imgError: false,
180
+ actionCloseFlag: 0 // 关闭按钮位置 0是跟随图片 1固定右上角
154
181
  });
155
182
  _define_property(this, "scaleChange", (value)=>{
156
183
  let { maxScale, minScale } = this.state;
@@ -162,8 +189,24 @@ class ViewImage extends React.Component {
162
189
  }
163
190
  this.setState({
164
191
  scaleValue: value
192
+ }, ()=>{
193
+ this.moveActionClose();
165
194
  });
166
195
  });
196
+ _define_property(this, "moveActionClose", ()=>{
197
+ setTimeout(()=>{
198
+ const rect = document.getElementById('viewImgBody_pic').getBoundingClientRect();
199
+ if (rect.top >= 0 && rect.top <= (window.innerHeight || document.documentElement.clientHeight) - 40 && rect.right <= (window.innerWidth || document.documentElement.clientWidth) - 52) {
200
+ this.setState({
201
+ actionCloseFlag: 0
202
+ });
203
+ } else {
204
+ this.setState({
205
+ actionCloseFlag: 1
206
+ });
207
+ }
208
+ }, 10);
209
+ });
167
210
  _define_property(this, "moveImg", (ev)=>{
168
211
  let { imgLeft, imgTop } = this.state;
169
212
  ev.preventDefault();
@@ -181,7 +224,9 @@ class ViewImage extends React.Component {
181
224
  this.setState({
182
225
  imgLeft: ev.pageX - disx,
183
226
  imgTop: ev.pageY - disy
184
- }, ()=>{});
227
+ }, ()=>{
228
+ this.moveActionClose();
229
+ });
185
230
  };
186
231
  const mouseUp = ()=>{
187
232
  document.removeEventListener("mousemove", mouseMove);