@cloud-app-dev/vidc 3.2.35 → 3.2.37

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.
@@ -149,8 +149,8 @@ function DomMove(_ref) {
149
149
  DomMove.defaultProps = {
150
150
  className: '',
151
151
  size: {
152
- width: 'max-content',
153
- height: 'max-content'
152
+ width: '100%',
153
+ height: '100%'
154
154
  }
155
155
  };
156
156
  export default /*#__PURE__*/React.forwardRef(function (props, ref) {
File without changes
File without changes
@@ -17,19 +17,21 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
17
 
18
18
  import React from 'react';
19
19
  import Picture from '.';
20
- import { useSimpleState } from '..';
20
+ import { Modal, useSimpleState } from '..';
21
21
  import { jsx as _jsx } from "react/jsx-runtime";
22
+ import { jsxs as _jsxs } from "react/jsx-runtime";
22
23
  export default function App() {
23
24
  var _useSimpleState = useSimpleState({
24
- open: false
25
+ open: false,
26
+ open2: false
25
27
  }),
26
28
  _useSimpleState2 = _slicedToArray(_useSimpleState, 2),
27
29
  state = _useSimpleState2[0],
28
30
  updateState = _useSimpleState2[1];
29
31
 
30
- return /*#__PURE__*/_jsx(_ConfigProvider, {
32
+ return /*#__PURE__*/_jsxs(_ConfigProvider, {
31
33
  prefixCls: "cloudapp",
32
- children: /*#__PURE__*/_jsx("div", {
34
+ children: [/*#__PURE__*/_jsx("div", {
33
35
  style: {
34
36
  width: 800,
35
37
  height: 600,
@@ -43,23 +45,23 @@ export default function App() {
43
45
  pathname: '/',
44
46
  icon: ''
45
47
  }],
46
- imagePath: "http://192.168.100.246:1443/image/v1/100005251/objects/63882cf105f5f58310107e95/1669910400.jpg?signature=ad407ae3019acb29b14b4ed2817ad12f&watermark=m_61646D696E0A323032323132303154313332373434&expires=1669910400",
48
+ imagePath: "http://192.168.100.246:5463/oss/v1/100004008/objects/638da35805f5f0a8101021f9?client_token=100004008_0_1670313176_9a47a8459c120d977904c9feb2354a7e",
47
49
  isOpenSelect: state.open,
48
50
  rects: [{
49
51
  type: 'face',
50
- rect: [698, 274, 23, 23],
52
+ rect: [10, 20, 23, 23],
51
53
  needExpand: true
52
54
  }, {
53
55
  type: 'face',
54
- rect: [754.0, 268.0, 23.0, 23.0],
56
+ rect: [20, 25, 23.0, 23.0],
55
57
  needExpand: true
56
58
  }, {
57
59
  type: 'face',
58
- rect: [430.0, 421.0, 49.0, 49.0],
60
+ rect: [40, 20.0, 49.0, 49.0],
59
61
  needExpand: true
60
62
  }, {
61
63
  type: 'face',
62
- rect: [240.0, 468.0, 41.0, 36.0],
64
+ rect: [35.0, 70.0, 41.0, 36.0],
63
65
  needExpand: true
64
66
  }],
65
67
  children: function children() {
@@ -73,6 +75,57 @@ export default function App() {
73
75
  });
74
76
  }
75
77
  })
76
- })
78
+ }), /*#__PURE__*/_jsxs("div", {
79
+ style: {
80
+ width: 800,
81
+ height: 600,
82
+ background: '#000',
83
+ marginTop: 40
84
+ },
85
+ children: [/*#__PURE__*/_jsx(_Button, {
86
+ onClick: function onClick() {
87
+ return updateState({
88
+ open2: true
89
+ });
90
+ },
91
+ children: "\u6253\u5F00"
92
+ }), /*#__PURE__*/_jsx(Modal, {
93
+ title: "modal",
94
+ open: state.open2,
95
+ onCancel: function onCancel() {
96
+ return updateState({
97
+ open2: false
98
+ });
99
+ },
100
+ width: 844,
101
+ children: /*#__PURE__*/_jsx("div", {
102
+ style: {
103
+ width: 800,
104
+ height: 600
105
+ },
106
+ children: /*#__PURE__*/_jsx(Picture, {
107
+ imagePath: "http://192.168.100.246:5463/oss/v1/100004008/objects/638da35805f5f0a8101021f9?client_token=100004008_0_1670313176_9a47a8459c120d977904c9feb2354a7e",
108
+ isOpenSelect: false,
109
+ rects: [{
110
+ type: 'face',
111
+ rect: [698, 274, 23, 23],
112
+ needExpand: true
113
+ }, {
114
+ type: 'face',
115
+ rect: [754.0, 268.0, 23.0, 23.0],
116
+ needExpand: true
117
+ }, {
118
+ type: 'face',
119
+ rect: [430.0, 421.0, 49.0, 49.0],
120
+ needExpand: true
121
+ }, {
122
+ type: 'face',
123
+ rect: [240.0, 468.0, 41.0, 36.0],
124
+ needExpand: true
125
+ }]
126
+ })
127
+ })
128
+ })]
129
+ })]
77
130
  });
78
131
  }
@@ -82,7 +82,8 @@ function Picture(_ref) {
82
82
  forceUpdateKey: Date.now(),
83
83
  fullScreenStatus: false,
84
84
  localUrl: '',
85
- offset: [0, 0]
85
+ offset: [0, 0],
86
+ size: ['auto', 'auto']
86
87
  }),
87
88
  _useSimpleState2 = _slicedToArray(_useSimpleState, 3),
88
89
  state = _useSimpleState2[0],
@@ -122,7 +123,7 @@ function Picture(_ref) {
122
123
  var loadImageSuccess = _useMemoizedFn( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
123
124
  var _layoutRef$current2, _layoutRect$width, _layoutRect$height;
124
125
 
125
- var img, naturalWidth, naturalHeight, layoutRect, w, h, baseXOrY, x, y, imagescale, imgHeight, _imagescale, imgWidth, moveObj;
126
+ var img, naturalWidth, naturalHeight, layoutRect, w, h, baseXOrY, x, y, size, imagescale, imgHeight, _imagescale, imgWidth, moveObj;
126
127
 
127
128
  return _regeneratorRuntime().wrap(function _callee$(_context) {
128
129
  while (1) {
@@ -144,17 +145,38 @@ function Picture(_ref) {
144
145
  baseXOrY = naturalWidth > naturalHeight ? 'x' : 'y';
145
146
  x = 0;
146
147
  y = 0;
148
+ size = []; // 横图
147
149
 
148
150
  if (baseXOrY === 'x') {
149
- imagescale = w / naturalWidth;
150
- imgHeight = imagescale * naturalHeight;
151
- y = Math.abs((imgHeight - h) / 2);
152
- img.width = w;
151
+ if (naturalWidth < w) {
152
+ // 图片小于容器
153
+ size[0] = naturalWidth;
154
+ size[1] = naturalHeight;
155
+ x = (w - naturalWidth) / 2;
156
+ y = Math.abs((h - naturalHeight) / 2);
157
+ } else {
158
+ // 图片大于容器
159
+ imagescale = w / naturalWidth;
160
+ imgHeight = imagescale * naturalHeight;
161
+ y = Math.abs((imgHeight - h) / 2);
162
+ size[0] = w;
163
+ size[1] = imgHeight;
164
+ }
153
165
  } else {
154
- _imagescale = h / naturalHeight;
155
- imgWidth = _imagescale * naturalWidth;
156
- x = Math.abs((imgWidth - w) / 2);
157
- img.height = h;
166
+ if (naturalHeight < h) {
167
+ // 图片小于容器
168
+ size[0] = naturalWidth;
169
+ size[1] = naturalHeight;
170
+ x = Math.abs(w - naturalWidth) / 2;
171
+ y = (h - naturalHeight) / 2;
172
+ } else {
173
+ // 图片大于容器
174
+ _imagescale = h / naturalHeight;
175
+ imgWidth = _imagescale * naturalWidth;
176
+ x = Math.abs((imgWidth - w) / 2);
177
+ size[0] = imgWidth;
178
+ size[1] = h;
179
+ }
158
180
  }
159
181
 
160
182
  moveObj = moveActionRef.current;
@@ -168,11 +190,12 @@ function Picture(_ref) {
168
190
  y: y,
169
191
  offset: [x, y],
170
192
  forceUpdateKey: Date.now(),
171
- baseXOrY: baseXOrY
193
+ baseXOrY: baseXOrY,
194
+ size: size
172
195
  });
173
196
  });
174
197
 
175
- case 14:
198
+ case 15:
176
199
  case "end":
177
200
  return _context.stop();
178
201
  }
@@ -364,6 +387,10 @@ function Picture(_ref) {
364
387
  ref: domImgRef,
365
388
  draggable: false,
366
389
  src: state.localUrl,
390
+ style: {
391
+ width: state.size[0],
392
+ height: state.size[1]
393
+ },
367
394
  "data-src": imagePath,
368
395
  onLoad: loadImageSuccess
369
396
  }), !isEmpty ? /*#__PURE__*/_jsx(DrawRect, {
@@ -87,13 +87,13 @@ export function computedRectScale(_ref) {
87
87
  var rect = item.needExpand ? getCaptureRect(cloneDeep(item.rect), item.type) : cloneDeep(item.rect);
88
88
  rect[0] = Math.round(rect[0] * scaleOptions.scaleX);
89
89
  rect[0] < 0 && (rect[0] = 0);
90
- rect[2] = Math.round(rect[2] * scaleOptions.scaleX);
91
- rect[2] < 0 && (rect[2] = 0);
92
90
  rect[1] = Math.round(rect[1] * scaleOptions.scaleY);
93
91
  rect[1] < 0 && (rect[1] = 0);
92
+ rect[2] = Math.round(rect[2] * scaleOptions.scaleX);
93
+ rect[2] < 0 && (rect[2] = 0);
94
+ rect[2] > width - rect[0] && (rect[2] = width - rect[0]);
94
95
  rect[3] = Math.round(rect[3] * scaleOptions.scaleY);
95
96
  rect[3] < 0 && (rect[3] = 0);
96
- rect[2] > width - rect[0] && (rect[2] = width - rect[0]);
97
97
  rect[3] > height - rect[1] && (rect[3] = height - rect[1]);
98
98
  return _objectSpread(_objectSpread({}, item), {}, {
99
99
  rect: rect
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "private": false,
3
3
  "name": "@cloud-app-dev/vidc",
4
4
  "description": "Video Image Data Componennts",
5
- "version": "3.2.35",
5
+ "version": "3.2.37",
6
6
  "scripts": {
7
7
  "docs:deploy": "gh-pages -d docs-dist",
8
8
  "build": "npm run entry && father build",
@@ -66,7 +66,7 @@
66
66
  "@types/react-dom": "^18.0.6",
67
67
  "antd": "^4.22.6",
68
68
  "babel-plugin-import": "^1.13.5",
69
- "dumi": "^2.0.10",
69
+ "dumi": "^2.0.11",
70
70
  "gh-pages": "^4.0.0",
71
71
  "react": "^18.2.0",
72
72
  "react-dom": "^18.2.0",