@trendr/core 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trendr/core",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "direct-mode TUI renderer with JSX, signals, and per-cell diffing",
5
5
  "license": "MIT",
6
6
  "author": "Jonathan Pyers",
package/src/scroll-box.js CHANGED
@@ -8,12 +8,17 @@ export function ScrollBox({ children, focused = true, scrollOffset: offsetProp,
8
8
  const layout = useLayout()
9
9
 
10
10
  const offset = offsetProp ?? offsetInternal()
11
- const setOffset = onScroll ?? setOffsetInternal
12
11
 
13
12
  const visibleH = layout.height
14
13
  const contentH = layout.contentHeight ?? 0
15
14
  const maxOffset = Math.max(0, contentH - visibleH)
16
15
 
16
+ const setOffset = (v) => {
17
+ const next = Math.max(0, Math.min(maxOffset, v))
18
+ if (onScroll) onScroll(next, { atBottom: next >= maxOffset, maxOffset })
19
+ else setOffsetInternal(next)
20
+ }
21
+
17
22
  const clamp = (v) => Math.max(0, Math.min(maxOffset, v))
18
23
  const clamped = clamp(offset)
19
24