Fix dependency ordering
This commit is contained in:
parent
b1d227b65f
commit
c2de10c076
|
@ -39,5 +39,10 @@ export const attachStores = context => {
|
|||
context = { ...context, ...store.deriveStores?.(context) }
|
||||
}
|
||||
|
||||
// Initialise any store logic
|
||||
for (let store of DependencyOrderedStores) {
|
||||
store.initialise?.(context)
|
||||
}
|
||||
|
||||
return context
|
||||
}
|
||||
|
|
|
@ -20,20 +20,8 @@ export const createStores = () => {
|
|||
}
|
||||
|
||||
export const deriveStores = context => {
|
||||
const {
|
||||
scroll,
|
||||
rows,
|
||||
visibleColumns,
|
||||
stickyColumn,
|
||||
bounds,
|
||||
rowHeight,
|
||||
focusedRow,
|
||||
focusedCellId,
|
||||
scrollTop,
|
||||
scrollLeft,
|
||||
width,
|
||||
height,
|
||||
} = context
|
||||
const { rows, visibleColumns, stickyColumn, rowHeight, width, height } =
|
||||
context
|
||||
|
||||
// Memoize store primitives
|
||||
const stickyColumnWidth = derived(stickyColumn, $col => $col?.width || 0, 0)
|
||||
|
@ -75,6 +63,45 @@ export const deriveStores = context => {
|
|||
0
|
||||
)
|
||||
|
||||
// Derive whether to show scrollbars or not
|
||||
const showVScrollbar = derived(
|
||||
[contentHeight, height],
|
||||
([$contentHeight, $height]) => {
|
||||
return $contentHeight > $height
|
||||
}
|
||||
)
|
||||
const showHScrollbar = derived(
|
||||
[contentWidth, screenWidth],
|
||||
([$contentWidth, $screenWidth]) => {
|
||||
return $contentWidth > $screenWidth
|
||||
}
|
||||
)
|
||||
|
||||
return {
|
||||
contentHeight,
|
||||
contentWidth,
|
||||
screenWidth,
|
||||
maxScrollTop,
|
||||
maxScrollLeft,
|
||||
showHScrollbar,
|
||||
showVScrollbar,
|
||||
}
|
||||
}
|
||||
|
||||
export const initialise = context => {
|
||||
const {
|
||||
focusedCellId,
|
||||
focusedRow,
|
||||
scroll,
|
||||
bounds,
|
||||
rowHeight,
|
||||
visibleColumns,
|
||||
scrollTop,
|
||||
maxScrollTop,
|
||||
scrollLeft,
|
||||
maxScrollLeft,
|
||||
} = context
|
||||
|
||||
// Ensure scroll state never goes invalid, which can happen when changing
|
||||
// rows or tables
|
||||
const overscrollTop = derived(
|
||||
|
@ -171,28 +198,4 @@ export const deriveStores = context => {
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Derive whether to show scrollbars or not
|
||||
const showVScrollbar = derived(
|
||||
[contentHeight, height],
|
||||
([$contentHeight, $height]) => {
|
||||
return $contentHeight > $height
|
||||
}
|
||||
)
|
||||
const showHScrollbar = derived(
|
||||
[contentWidth, screenWidth],
|
||||
([$contentWidth, $screenWidth]) => {
|
||||
return $contentWidth > $screenWidth
|
||||
}
|
||||
)
|
||||
|
||||
return {
|
||||
contentHeight,
|
||||
contentWidth,
|
||||
screenWidth,
|
||||
maxScrollTop,
|
||||
maxScrollLeft,
|
||||
showHScrollbar,
|
||||
showVScrollbar,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue