(
event,
)
| 523 | ) |
| 524 | |
| 525 | const handleDragStart: JSX.EventHandler<HTMLDivElement, MouseEvent> = ( |
| 526 | event, |
| 527 | ) => { |
| 528 | const panelElement = event.currentTarget.parentElement |
| 529 | if (!panelElement) return |
| 530 | setIsResizing(true) |
| 531 | const { height, width } = panelElement.getBoundingClientRect() |
| 532 | const startX = event.clientX |
| 533 | const startY = event.clientY |
| 534 | let newSize = 0 |
| 535 | const minHeight = convertRemToPixels(3.5) |
| 536 | const minWidth = convertRemToPixels(12) |
| 537 | const runDrag = (moveEvent: MouseEvent) => { |
| 538 | moveEvent.preventDefault() |
| 539 | |
| 540 | if (position() === 'left' || position() === 'right') { |
| 541 | const valToAdd = |
| 542 | position() === 'right' |
| 543 | ? startX - moveEvent.clientX |
| 544 | : moveEvent.clientX - startX |
| 545 | newSize = Math.round(width + valToAdd) |
| 546 | if (newSize < minWidth) { |
| 547 | newSize = minWidth |
| 548 | } |
| 549 | props.setLocalStore('width', String(Math.round(newSize))) |
| 550 | |
| 551 | const newWidth = panelElement.getBoundingClientRect().width |
| 552 | // If the panel size didn't decrease, this means we have reached the minimum width |
| 553 | // of the panel so we restore the original width in local storage |
| 554 | // Restoring the width helps in smooth open/close transitions |
| 555 | if (Number(props.localStore.width) < newWidth) { |
| 556 | props.setLocalStore('width', String(newWidth)) |
| 557 | } |
| 558 | } else { |
| 559 | const valToAdd = |
| 560 | position() === 'bottom' |
| 561 | ? startY - moveEvent.clientY |
| 562 | : moveEvent.clientY - startY |
| 563 | newSize = Math.round(height + valToAdd) |
| 564 | // If the panel size is less than the minimum height, |
| 565 | // we set the size to the minimum height |
| 566 | if (newSize < minHeight) { |
| 567 | newSize = minHeight |
| 568 | setSelectedQueryHash(null) |
| 569 | } |
| 570 | props.setLocalStore('height', String(Math.round(newSize))) |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | const unsubscribe = () => { |
| 575 | if (isResizing()) { |
| 576 | setIsResizing(false) |
| 577 | } |
| 578 | document.removeEventListener('mousemove', runDrag, false) |
| 579 | document.removeEventListener('mouseup', unsubscribe, false) |
| 580 | } |
| 581 | |
| 582 | document.addEventListener('mousemove', runDrag, false) |
nothing calls this directly
no test coverage detected