@cloud-app-dev/vidc 3.2.36 → 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.
File without changes
File without changes
@@ -49,19 +49,19 @@ export default function App() {
49
49
  isOpenSelect: state.open,
50
50
  rects: [{
51
51
  type: 'face',
52
- rect: [698, 274, 23, 23],
52
+ rect: [10, 20, 23, 23],
53
53
  needExpand: true
54
54
  }, {
55
55
  type: 'face',
56
- rect: [754.0, 268.0, 23.0, 23.0],
56
+ rect: [20, 25, 23.0, 23.0],
57
57
  needExpand: true
58
58
  }, {
59
59
  type: 'face',
60
- rect: [430.0, 421.0, 49.0, 49.0],
60
+ rect: [40, 20.0, 49.0, 49.0],
61
61
  needExpand: true
62
62
  }, {
63
63
  type: 'face',
64
- rect: [240.0, 468.0, 41.0, 36.0],
64
+ rect: [35.0, 70.0, 41.0, 36.0],
65
65
  needExpand: true
66
66
  }],
67
67
  children: function children() {
@@ -105,7 +105,24 @@ export default function App() {
105
105
  },
106
106
  children: /*#__PURE__*/_jsx(Picture, {
107
107
  imagePath: "http://192.168.100.246:5463/oss/v1/100004008/objects/638da35805f5f0a8101021f9?client_token=100004008_0_1670313176_9a47a8459c120d977904c9feb2354a7e",
108
- isOpenSelect: false
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
+ }]
109
126
  })
110
127
  })
111
128
  })]
@@ -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
  }
@@ -365,8 +388,8 @@ function Picture(_ref) {
365
388
  draggable: false,
366
389
  src: state.localUrl,
367
390
  style: {
368
- width: state.baseXOrY === 'x' ? '100%' : 'auto',
369
- height: state.baseXOrY === 'y' ? '100%' : 'auto'
391
+ width: state.size[0],
392
+ height: state.size[1]
370
393
  },
371
394
  "data-src": imagePath,
372
395
  onLoad: loadImageSuccess
@@ -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.36",
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",