Fix pixel layout issues with buttons column
This commit is contained in:
parent
b58519d562
commit
5d06a53d37
|
@ -14,7 +14,7 @@
|
||||||
focusedRow,
|
focusedRow,
|
||||||
selectedRows,
|
selectedRows,
|
||||||
scrollableColumns,
|
scrollableColumns,
|
||||||
scroll,
|
scrollLeft,
|
||||||
isDragging,
|
isDragging,
|
||||||
buttonColumnWidth,
|
buttonColumnWidth,
|
||||||
showVScrollbar,
|
showVScrollbar,
|
||||||
|
@ -28,8 +28,8 @@
|
||||||
(total, col) => (total += col.width),
|
(total, col) => (total += col.width),
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
$: columnEnd = columnsWidth - $scroll.left - 1
|
$: columnEnd = columnsWidth - $scrollLeft - 1
|
||||||
$: gridEnd = $width - $buttonColumnWidth
|
$: gridEnd = $width - $buttonColumnWidth - 1
|
||||||
$: left = Math.min(columnEnd, gridEnd)
|
$: left = Math.min(columnEnd, gridEnd)
|
||||||
|
|
||||||
const handleClick = async (button, row) => {
|
const handleClick = async (button, row) => {
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const observer = new ResizeObserver(entries => {
|
const observer = new ResizeObserver(entries => {
|
||||||
const width = entries?.[0]?.contentRect?.width ?? 0
|
const width = entries?.[0]?.contentRect?.width ?? 0
|
||||||
buttonColumnWidth.set(width)
|
buttonColumnWidth.set(Math.floor(width) - 1)
|
||||||
})
|
})
|
||||||
observer.observe(container)
|
observer.observe(container)
|
||||||
})
|
})
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
hoveredRowId,
|
hoveredRowId,
|
||||||
menu,
|
menu,
|
||||||
focusedCellAPI,
|
focusedCellAPI,
|
||||||
|
scrollTop,
|
||||||
|
scrollLeft,
|
||||||
} = getContext("grid")
|
} = getContext("grid")
|
||||||
|
|
||||||
export let scrollVertically = false
|
export let scrollVertically = false
|
||||||
|
@ -24,11 +26,11 @@
|
||||||
let initialTouchX
|
let initialTouchX
|
||||||
let initialTouchY
|
let initialTouchY
|
||||||
|
|
||||||
$: style = generateStyle($scroll, $rowHeight)
|
$: style = generateStyle($scrollLeft, $scrollTop, $rowHeight)
|
||||||
|
|
||||||
const generateStyle = (scroll, rowHeight) => {
|
const generateStyle = (scrollLeft, scrollTop, rowHeight) => {
|
||||||
const offsetX = scrollHorizontally ? -1 * scroll.left : 0
|
const offsetX = scrollHorizontally ? -1 * scrollLeft : 0
|
||||||
const offsetY = scrollVertically ? -1 * (scroll.top % rowHeight) : 0
|
const offsetY = scrollVertically ? -1 * (scrollTop % rowHeight) : 0
|
||||||
return `transform: translate3d(${offsetX}px, ${offsetY}px, 0);`
|
return `transform: translate3d(${offsetX}px, ${offsetY}px, 0);`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,14 @@
|
||||||
import { Icon } from "@budibase/bbui"
|
import { Icon } from "@budibase/bbui"
|
||||||
import GridPopover from "../overlays/GridPopover.svelte"
|
import GridPopover from "../overlays/GridPopover.svelte"
|
||||||
|
|
||||||
const { scrollableColumns, scroll, width, subscribe, ui, keyboardBlocked } =
|
const {
|
||||||
getContext("grid")
|
scrollableColumns,
|
||||||
|
scrollLeft,
|
||||||
|
width,
|
||||||
|
subscribe,
|
||||||
|
ui,
|
||||||
|
keyboardBlocked,
|
||||||
|
} = getContext("grid")
|
||||||
|
|
||||||
let anchor
|
let anchor
|
||||||
let isOpen = false
|
let isOpen = false
|
||||||
|
@ -13,7 +19,7 @@
|
||||||
(total, col) => (total += col.width),
|
(total, col) => (total += col.width),
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
$: end = columnsWidth - 1 - $scroll.left
|
$: end = columnsWidth - 1 - $scrollLeft
|
||||||
$: left = Math.min($width - 40, end)
|
$: left = Math.min($width - 40, end)
|
||||||
$: keyboardBlocked.set(isOpen)
|
$: keyboardBlocked.set(isOpen)
|
||||||
|
|
||||||
|
|
|
@ -119,12 +119,12 @@ export const createActions = context => {
|
||||||
// Actual logic to consider the current position and determine the new order
|
// Actual logic to consider the current position and determine the new order
|
||||||
const considerReorderPosition = () => {
|
const considerReorderPosition = () => {
|
||||||
const $reorder = get(reorder)
|
const $reorder = get(reorder)
|
||||||
const $scroll = get(scroll)
|
const $scrollLeft = get(scrollLeft)
|
||||||
|
|
||||||
// Compute the closest breakpoint to the current position
|
// Compute the closest breakpoint to the current position
|
||||||
let breakpoint
|
let breakpoint
|
||||||
let minDistance = Number.MAX_SAFE_INTEGER
|
let minDistance = Number.MAX_SAFE_INTEGER
|
||||||
const mouseX = latestX - $reorder.gridLeft + $scroll.left
|
const mouseX = latestX - $reorder.gridLeft + $scrollLeft
|
||||||
$reorder.breakpoints.forEach(point => {
|
$reorder.breakpoints.forEach(point => {
|
||||||
const distance = Math.abs(point.x - mouseX)
|
const distance = Math.abs(point.x - mouseX)
|
||||||
if (distance < minDistance) {
|
if (distance < minDistance) {
|
||||||
|
|
|
@ -16,8 +16,8 @@ export const createStores = () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Derive height and width as primitives to avoid wasted computation
|
// Derive height and width as primitives to avoid wasted computation
|
||||||
const scrollTop = derived(scroll, $scroll => $scroll.top, 0)
|
const scrollTop = derived(scroll, $scroll => Math.round($scroll.top))
|
||||||
const scrollLeft = derived(scroll, $scroll => $scroll.left, 0)
|
const scrollLeft = derived(scroll, $scroll => Math.round($scroll.left))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
scroll,
|
scroll,
|
||||||
|
@ -46,11 +46,11 @@ export const deriveStores = context => {
|
||||||
const contentWidth = derived(
|
const contentWidth = derived(
|
||||||
[visibleColumns, buttonColumnWidth],
|
[visibleColumns, buttonColumnWidth],
|
||||||
([$visibleColumns, $buttonColumnWidth]) => {
|
([$visibleColumns, $buttonColumnWidth]) => {
|
||||||
let width = GutterWidth + $buttonColumnWidth
|
let width = GutterWidth + Math.max($buttonColumnWidth, HPadding)
|
||||||
$visibleColumns.forEach(col => {
|
$visibleColumns.forEach(col => {
|
||||||
width += col.width
|
width += col.width
|
||||||
})
|
})
|
||||||
return width + HPadding
|
return width
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const screenWidth = derived(
|
const screenWidth = derived(
|
||||||
|
@ -62,7 +62,7 @@ export const deriveStores = context => {
|
||||||
const maxScrollLeft = derived(
|
const maxScrollLeft = derived(
|
||||||
[contentWidth, screenWidth],
|
[contentWidth, screenWidth],
|
||||||
([$contentWidth, $screenWidth]) => {
|
([$contentWidth, $screenWidth]) => {
|
||||||
return Math.max($contentWidth - $screenWidth, 0)
|
return Math.round(Math.max($contentWidth - $screenWidth, 0))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const showHScrollbar = derived(
|
const showHScrollbar = derived(
|
||||||
|
@ -85,7 +85,8 @@ export const deriveStores = context => {
|
||||||
)
|
)
|
||||||
const maxScrollTop = derived(
|
const maxScrollTop = derived(
|
||||||
[height, contentHeight],
|
[height, contentHeight],
|
||||||
([$height, $contentHeight]) => Math.max($contentHeight - $height, 0)
|
([$height, $contentHeight]) =>
|
||||||
|
Math.round(Math.max($contentHeight - $height, 0))
|
||||||
)
|
)
|
||||||
const showVScrollbar = derived(
|
const showVScrollbar = derived(
|
||||||
[contentHeight, height],
|
[contentHeight, height],
|
||||||
|
|
Loading…
Reference in New Issue