This commit is contained in:
Andrew Kingston 2023-04-17 16:04:41 +01:00
parent 1c702d5f07
commit e48e2ff7f0
3 changed files with 5 additions and 16 deletions

View File

@ -118,7 +118,7 @@
{/if}
</div>
<SheetScrollWrapper scrollHorizontally wheelInteractive foo>
<SheetScrollWrapper scrollHorizontally wheelInteractive>
<div class="row">
{#each $visibleColumns as column}
{@const cellId = `new-${column.name}`}

View File

@ -10,12 +10,10 @@
focusedCellId,
reorder,
selectedRows,
visibleColumns,
renderedColumns,
hoveredRowId,
selectedCellMap,
focusedRow,
hiddenColumnsWidth,
columnHorizontalInversionIndex,
} = getContext("sheet")
@ -23,8 +21,6 @@
$: rowHovered = $hoveredRowId === row._id
$: rowFocused = $focusedRow?._id === row._id
$: reorderSource = $reorder.sourceColumn
$: cols = rowFocused ? $visibleColumns : $renderedColumns
$: foo = `margin-left: ${-1 * $hiddenColumnsWidth}px;`
</script>
<div

View File

@ -17,19 +17,12 @@
export let scrollVertically = false
export let scrollHorizontally = false
export let wheelInteractive = false
export let foo = false
$: style = generateStyle($scroll, $rowHeight, $hiddenColumnsWidth, foo)
$: style = generateStyle($scroll, $rowHeight, $hiddenColumnsWidth)
const generateStyle = (scroll, rowHeight, hiddenWidths, foo) => {
let offsetX, offsetY
if (!foo) {
offsetX = scrollHorizontally ? -1 * scroll.left + hiddenWidths : 0
offsetY = scrollVertically ? -1 * (scroll.top % rowHeight) : 0
} else {
offsetX = scrollHorizontally ? -1 * scroll.left : 0
offsetY = scrollVertically ? -1 * scroll.top : 0
}
const generateStyle = (scroll, rowHeight, hiddenWidths) => {
const offsetX = scrollHorizontally ? -1 * scroll.left + hiddenWidths : 0
const offsetY = scrollVertically ? -1 * (scroll.top % rowHeight) : 0
return `transform: translate3d(${offsetX}px, ${offsetY}px, 0);`
}