MCPcopy Create free account
hub / github.com/TanStack/query / runDrag

Function runDrag

packages/query-devtools/src/Devtools.tsx:537–572  ·  view source on GitHub ↗
(moveEvent: MouseEvent)

Source from the content-addressed store, hash-verified

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()) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected