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

Function runDrag

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

Source from the content-addressed store, hash-verified

431 const minHeight = convertRemToPixels(3.5)
432 const minWidth = convertRemToPixels(12)
433 const runDrag = (moveEvent: MouseEvent) => {
434 moveEvent.preventDefault()
435
436 if (position() === 'left' || position() === 'right') {
437 const valToAdd =
438 position() === 'right'
439 ? startX - moveEvent.clientX
440 : moveEvent.clientX - startX
441 newSize = Math.round(width + valToAdd)
442 if (newSize < minWidth) {
443 newSize = minWidth
444 }
445 props.setLocalStore('width', String(Math.round(newSize)))
446
447 const newWidth = panelElement.getBoundingClientRect().width
448 // If the panel size didn't decrease, this means we have reached the minimum width
449 // of the panel so we restore the original width in local storage
450 // Restoring the width helps in smooth open/close transitions
451 if (Number(props.localStore.width) < newWidth) {
452 props.setLocalStore('width', String(newWidth))
453 }
454 } else {
455 const valToAdd =
456 position() === 'bottom'
457 ? startY - moveEvent.clientY
458 : moveEvent.clientY - startY
459 newSize = Math.round(height + valToAdd)
460 // If the panel size is less than the minimum height,
461 // we set the size to the minimum height
462 if (newSize < minHeight) {
463 newSize = minHeight
464 setSelectedQueryHash(null)
465 }
466 props.setLocalStore('height', String(Math.round(newSize)))
467 }
468 }
469
470 const unsubscribe = () => {
471 if (isResizing()) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected