@@ -236,108 +236,123 @@ export class BoxResizingInstance extends Component<{ |
236 | 236 |
|
237 | 237 | render() { |
238 | 238 | const { observed } = this.props; |
239 | | - if (!observed.hasOffset) { |
240 | | - return null; |
241 | | - } |
242 | | - |
243 | | - const { node, offsetWidth, offsetHeight, offsetTop, offsetLeft } = observed; |
244 | 239 | let triggerVisible: any = []; |
245 | | - const { advanced } = node.componentMeta; |
246 | | - if (advanced.getResizingHandlers) { |
247 | | - triggerVisible = advanced.getResizingHandlers(node.internalToShellNode()); |
| 240 | + let offsetWidth = 0; |
| 241 | + let offsetHeight = 0; |
| 242 | + let offsetTop = 0; |
| 243 | + let offsetLeft = 0; |
| 244 | + if (observed.hasOffset) { |
| 245 | + offsetWidth = observed.offsetWidth; |
| 246 | + offsetHeight = observed.offsetHeight; |
| 247 | + offsetTop = observed.offsetTop; |
| 248 | + offsetLeft = observed.offsetLeft; |
| 249 | + const { node } = observed; |
| 250 | + const metadata = node.componentMeta.getMetadata(); |
| 251 | + if (metadata.configure?.advanced?.getResizingHandlers) { |
| 252 | + triggerVisible = metadata.configure.advanced.getResizingHandlers(node.internalToShellNode()); |
| 253 | + } |
248 | 254 | } |
249 | | - |
250 | 255 | triggerVisible = normalizeTriggers(triggerVisible); |
251 | 256 |
|
252 | 257 | const baseSideClass = 'lc-borders lc-resize-side'; |
253 | 258 | const baseCornerClass = 'lc-borders lc-resize-corner'; |
254 | 259 |
|
255 | 260 | return ( |
256 | 261 | <div> |
257 | | - {triggerVisible.includes('N') && ( |
258 | | - <div |
259 | | - ref={(ref) => { this.outlineN = ref; }} |
260 | | - className={classNames(baseSideClass, 'n')} |
261 | | - style={{ |
262 | | - height: 20, |
263 | | - transform: `translate(${offsetLeft}px, ${offsetTop - 10}px)`, |
264 | | - width: offsetWidth, |
265 | | - }} |
266 | | - /> |
267 | | - )} |
268 | | - {triggerVisible.includes('NE') && ( |
269 | | - <div |
270 | | - ref={(ref) => { this.outlineNE = ref; }} |
271 | | - className={classNames(baseCornerClass, 'ne')} |
272 | | - style={{ |
273 | | - transform: `translate(${offsetLeft + offsetWidth - 5}px, ${offsetTop - 3}px)`, |
274 | | - cursor: 'nesw-resize', |
275 | | - }} |
276 | | - /> |
277 | | - )} |
278 | | - {triggerVisible.includes('E') && ( |
279 | | - <div |
280 | | - className={classNames(baseSideClass, 'e')} |
281 | | - ref={(ref) => { this.outlineE = ref; }} |
282 | | - style={{ |
283 | | - height: offsetHeight, |
284 | | - transform: `translate(${offsetLeft + offsetWidth - 10}px, ${offsetTop}px)`, |
285 | | - width: 20, |
286 | | - }} |
287 | | - /> |
288 | | - )} |
289 | | - {triggerVisible.includes('SE') && ( |
290 | | - <div |
291 | | - ref={(ref) => { this.outlineSE = ref; }} |
292 | | - className={classNames(baseCornerClass, 'se')} |
293 | | - style={{ |
294 | | - transform: `translate(${offsetLeft + offsetWidth - 5}px, ${offsetTop + offsetHeight - 5}px)`, |
295 | | - cursor: 'nwse-resize', |
296 | | - }} |
297 | | - /> |
298 | | - )} |
299 | | - {triggerVisible.includes('S') && ( |
300 | | - <div |
301 | | - ref={(ref) => { this.outlineS = ref; }} |
302 | | - className={classNames(baseSideClass, 's')} |
303 | | - style={{ |
304 | | - height: 20, |
305 | | - transform: `translate(${offsetLeft}px, ${offsetTop + offsetHeight - 10}px)`, |
306 | | - width: offsetWidth, |
307 | | - }} |
308 | | - /> |
309 | | - )} |
310 | | - {triggerVisible.includes('SW') && ( |
311 | | - <div |
312 | | - ref={(ref) => { this.outlineSW = ref; }} |
313 | | - className={classNames(baseCornerClass, 'sw')} |
314 | | - style={{ |
315 | | - transform: `translate(${offsetLeft - 3}px, ${offsetTop + offsetHeight - 5}px)`, |
316 | | - cursor: 'nesw-resize', |
317 | | - }} |
318 | | - /> |
319 | | - )} |
320 | | - {triggerVisible.includes('W') && ( |
321 | | - <div |
322 | | - ref={(ref) => { this.outlineW = ref; }} |
323 | | - className={classNames(baseSideClass, 'w')} |
324 | | - style={{ |
325 | | - height: offsetHeight, |
326 | | - transform: `translate(${offsetLeft - 10}px, ${offsetTop}px)`, |
327 | | - width: 20, |
328 | | - }} |
329 | | - /> |
330 | | - )} |
331 | | - {triggerVisible.includes('NW') && ( |
332 | | - <div |
333 | | - ref={(ref) => { this.outlineNW = ref; }} |
334 | | - className={classNames(baseCornerClass, 'nw')} |
335 | | - style={{ |
336 | | - transform: `translate(${offsetLeft - 3}px, ${offsetTop - 3}px)`, |
337 | | - cursor: 'nwse-resize', |
338 | | - }} |
339 | | - /> |
340 | | - )} |
| 262 | + <div |
| 263 | + ref={(ref) => { |
| 264 | + this.outlineN = ref; |
| 265 | + }} |
| 266 | + className={classNames(baseSideClass, 'n')} |
| 267 | + style={{ |
| 268 | + height: 20, |
| 269 | + transform: `translate(${offsetLeft}px, ${offsetTop - 10}px)`, |
| 270 | + width: offsetWidth, |
| 271 | + display: triggerVisible.includes('N') ? 'flex' : 'none', |
| 272 | + }} |
| 273 | + /> |
| 274 | + <div |
| 275 | + ref={(ref) => { |
| 276 | + this.outlineNE = ref; |
| 277 | + }} |
| 278 | + className={classNames(baseCornerClass, 'ne')} |
| 279 | + style={{ |
| 280 | + transform: `translate(${offsetLeft + offsetWidth - 5}px, ${offsetTop - 3}px)`, |
| 281 | + cursor: 'nesw-resize', |
| 282 | + display: triggerVisible.includes('NE') ? 'flex' : 'none', |
| 283 | + }} |
| 284 | + /> |
| 285 | + <div |
| 286 | + className={classNames(baseSideClass, 'e')} |
| 287 | + ref={(ref) => { |
| 288 | + this.outlineE = ref; |
| 289 | + }} |
| 290 | + style={{ |
| 291 | + height: offsetHeight, |
| 292 | + transform: `translate(${offsetLeft + offsetWidth - 10}px, ${offsetTop}px)`, |
| 293 | + width: 20, |
| 294 | + display: triggerVisible.includes('E') ? 'flex' : 'none', |
| 295 | + }} |
| 296 | + /> |
| 297 | + <div |
| 298 | + ref={(ref) => { |
| 299 | + this.outlineSE = ref; |
| 300 | + }} |
| 301 | + className={classNames(baseCornerClass, 'se')} |
| 302 | + style={{ |
| 303 | + transform: `translate(${offsetLeft + offsetWidth - 5}px, ${ |
| 304 | + offsetTop + offsetHeight - 5 |
| 305 | + }px)`, |
| 306 | + cursor: 'nwse-resize', |
| 307 | + display: triggerVisible.includes('SE') ? 'flex' : 'none', |
| 308 | + }} |
| 309 | + /> |
| 310 | + <div |
| 311 | + ref={(ref) => { |
| 312 | + this.outlineS = ref; |
| 313 | + }} |
| 314 | + className={classNames(baseSideClass, 's')} |
| 315 | + style={{ |
| 316 | + height: 20, |
| 317 | + transform: `translate(${offsetLeft}px, ${offsetTop + offsetHeight - 10}px)`, |
| 318 | + width: offsetWidth, |
| 319 | + display: triggerVisible.includes('S') ? 'flex' : 'none', |
| 320 | + }} |
| 321 | + /> |
| 322 | + <div |
| 323 | + ref={(ref) => { |
| 324 | + this.outlineSW = ref; |
| 325 | + }} |
| 326 | + className={classNames(baseCornerClass, 'sw')} |
| 327 | + style={{ |
| 328 | + transform: `translate(${offsetLeft - 3}px, ${offsetTop + offsetHeight - 5}px)`, |
| 329 | + cursor: 'nesw-resize', |
| 330 | + display: triggerVisible.includes('SW') ? 'flex' : 'none', |
| 331 | + }} |
| 332 | + /> |
| 333 | + <div |
| 334 | + ref={(ref) => { |
| 335 | + this.outlineW = ref; |
| 336 | + }} |
| 337 | + className={classNames(baseSideClass, 'w')} |
| 338 | + style={{ |
| 339 | + height: offsetHeight, |
| 340 | + transform: `translate(${offsetLeft - 10}px, ${offsetTop}px)`, |
| 341 | + width: 20, |
| 342 | + display: triggerVisible.includes('W') ? 'flex' : 'none', |
| 343 | + }} |
| 344 | + /> |
| 345 | + <div |
| 346 | + ref={(ref) => { |
| 347 | + this.outlineNW = ref; |
| 348 | + }} |
| 349 | + className={classNames(baseCornerClass, 'nw')} |
| 350 | + style={{ |
| 351 | + transform: `translate(${offsetLeft - 3}px, ${offsetTop - 3}px)`, |
| 352 | + cursor: 'nwse-resize', |
| 353 | + display: triggerVisible.includes('NW') ? 'flex' : 'none', |
| 354 | + }} |
| 355 | + /> |
341 | 356 | </div> |
342 | 357 | ); |
343 | 358 | } |
|