MCPcopy Index your code
hub / github.com/TanStack/table / updateOffset

Function updateOffset

packages/table-core/src/features/ColumnSizing.ts:373–414  ·  view source on GitHub ↗
(
          eventType: 'move' | 'end',
          clientXPos?: number
        )

Source from the content-addressed store, hash-verified

371 const newColumnSizing: ColumnSizingState = {}
372
373 const updateOffset = (
374 eventType: 'move' | 'end',
375 clientXPos?: number
376 ) => {
377 if (typeof clientXPos !== 'number') {
378 return
379 }
380
381 table.setColumnSizingInfo(old => {
382 const deltaDirection =
383 table.options.columnResizeDirection === 'rtl' ? -1 : 1
384 const deltaOffset =
385 (clientXPos - (old?.startOffset ?? 0)) * deltaDirection
386 const deltaPercentage = Math.max(
387 deltaOffset / (old?.startSize ?? 0),
388 -0.999999
389 )
390
391 old.columnSizingStart.forEach(([columnId, headerSize]) => {
392 newColumnSizing[columnId] =
393 Math.round(
394 Math.max(headerSize + headerSize * deltaPercentage, 0) * 100
395 ) / 100
396 })
397
398 return {
399 ...old,
400 deltaOffset,
401 deltaPercentage,
402 }
403 })
404
405 if (
406 table.options.columnResizeMode === 'onChange' ||
407 eventType === 'end'
408 ) {
409 table.setColumnSizing(old => ({
410 ...old,
411 ...newColumnSizing,
412 }))
413 }
414 }
415
416 const onMove = (clientXPos?: number) => updateOffset('move', clientXPos)
417

Callers 2

onMoveFunction · 0.85
onEndFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…