(
event,
)
| 433 | ) |
| 434 | |
| 435 | const handleDragStart: JSX.EventHandler<HTMLDivElement, MouseEvent> = ( |
| 436 | event, |
| 437 | ) => { |
| 438 | const panelElement = event.currentTarget.parentElement |
| 439 | if (!panelElement) return |
| 440 | setIsResizing(true) |
| 441 | const { height, width } = panelElement.getBoundingClientRect() |
| 442 | const startX = event.clientX |
| 443 | const startY = event.clientY |
| 444 | let newSize = 0 |
| 445 | const minHeight = convertRemToPixels(3.5) |
| 446 | const minWidth = convertRemToPixels(12) |
| 447 | const runDrag = (moveEvent: MouseEvent) => { |
| 448 | moveEvent.preventDefault() |
| 449 | |
| 450 | if (position() === 'left' || position() === 'right') { |
| 451 | const valToAdd = |
| 452 | position() === 'right' |
| 453 | ? startX - moveEvent.clientX |
| 454 | : moveEvent.clientX - startX |
| 455 | newSize = Math.round(width + valToAdd) |
| 456 | if (newSize < minWidth) { |
| 457 | newSize = minWidth |
| 458 | } |
| 459 | props.setLocalStore('width', String(Math.round(newSize))) |
| 460 | |
| 461 | const newWidth = panelElement.getBoundingClientRect().width |
| 462 | // If the panel size didn't decrease, this means we have reached the minimum width |
| 463 | // of the panel so we restore the original width in local storage |
| 464 | // Restoring the width helps in smooth open/close transitions |
| 465 | if (Number(props.localStore.width) < newWidth) { |
| 466 | props.setLocalStore('width', String(newWidth)) |
| 467 | } |
| 468 | } else { |
| 469 | const valToAdd = |
| 470 | position() === 'bottom' |
| 471 | ? startY - moveEvent.clientY |
| 472 | : moveEvent.clientY - startY |
| 473 | newSize = Math.round(height + valToAdd) |
| 474 | // If the panel size is less than the minimum height, |
| 475 | // we set the size to the minimum height |
| 476 | if (newSize < minHeight) { |
| 477 | newSize = minHeight |
| 478 | setSelectedQueryHash(null) |
| 479 | } |
| 480 | props.setLocalStore('height', String(Math.round(newSize))) |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | const unsubscribe = () => { |
| 485 | if (isResizing()) { |
| 486 | setIsResizing(false) |
| 487 | } |
| 488 | document.removeEventListener('mousemove', runDrag, false) |
| 489 | document.removeEventListener('mouseup', unsubscribe, false) |
| 490 | } |
| 491 | |
| 492 | document.addEventListener('mousemove', runDrag, false) |
nothing calls this directly
no test coverage detected