@svelte-lean/table 0.13.1 → 0.13.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @svelte-lean/table
2
2
 
3
+ ## 0.13.3
4
+
5
+ ### Patch Changes
6
+
7
+ - d30fe0c: A table wider than its region keeps its header in view: without `height`, a region that scrolls sideways used to leave the header behind as the page scrolled. The header now follows the page (a scroll-driven animation on the region's view timeline, run by the compositor), from `--slean-table-sticky-top` down to the table's last row. Browsers without scroll-driven animations keep the old behaviour.
8
+
9
+ ## 0.13.2
10
+
11
+ No changes in this release.
12
+
3
13
  ## 0.13.1
4
14
 
5
15
  No changes in this release.
package/dist/style.css CHANGED
@@ -327,6 +327,32 @@
327
327
  :where(.slean-table-scroll[data-page-sticky] > .slean-table-sticky > thead) {
328
328
  top: var(--slean-table-sticky-top, 0px);
329
329
  }
330
+ /* Sideways-only region: the header follows the page (data-table.svelte, `data-head-follows`). */
331
+ @supports (animation-timeline: view()) {
332
+ :where(.slean-table-scroll[data-head-follows]) {
333
+ view-timeline-name: --slean-table-region;
334
+ view-timeline-axis: block;
335
+ view-timeline-inset: var(--slean-table-sticky-top, 0px) 0px;
336
+ }
337
+ :where(.slean-table-scroll[data-head-follows] > table > thead) {
338
+ position: relative;
339
+ z-index: 5;
340
+ animation-name: slean-table-head-follow;
341
+ animation-duration: auto;
342
+ animation-timing-function: linear;
343
+ animation-fill-mode: both;
344
+ animation-timeline: --slean-table-region;
345
+ animation-range: exit-crossing 0px exit-crossing var(--slean-table-travel, 0px);
346
+ }
347
+ }
348
+ @keyframes slean-table-head-follow {
349
+ from {
350
+ translate: 0 0;
351
+ }
352
+ to {
353
+ translate: 0 var(--slean-table-travel, 0px);
354
+ }
355
+ }
330
356
  :where(
331
357
  .slean-table
332
358
  > .slean-table-scroll[data-page-sticky]:first-child
@@ -825,19 +825,26 @@
825
825
  * header without ever letting it stick; the header is then not sticky at all (`scrollsY`), since
826
826
  * a sticky box in a scroller is composited, and every row painted under it is weighed against it
827
827
  * (at 1000 rows about a tenth of a fast scroll's main-thread work).
828
+ *
829
+ * Such a header follows the page instead (`data-head-follows`, style.css): a scroll-driven
830
+ * animation on the region's view timeline moves it down by as much as the region has passed
831
+ * under the page's top, never past its last row (`--slean-table-travel`). The compositor runs
832
+ * it; script only measures the travel when a size changes.
828
833
  */
829
834
  let fits = $state(false);
830
835
  let scrollsY = $state(true);
836
+ let travel = $state(0);
831
837
  $effect(() => {
832
838
  if (!stickyHeader || height || typeof ResizeObserver === 'undefined') {
833
839
  fits = false;
834
840
  scrollsY = true;
835
841
  return;
836
842
  }
837
- const table = viewport.firstElementChild as HTMLElement;
843
+ const table = viewport.firstElementChild as HTMLTableElement;
838
844
  const observer = new ResizeObserver(() => {
839
845
  fits = table.offsetWidth <= viewport.clientWidth + 1;
840
846
  scrollsY = viewport.scrollHeight > viewport.clientHeight + 1;
847
+ travel = Math.max(0, table.offsetHeight - (table.tHead?.offsetHeight ?? 0));
841
848
  });
842
849
  observer.observe(viewport);
843
850
  observer.observe(table);
@@ -1683,6 +1690,10 @@
1683
1690
  bind:this={viewport}
1684
1691
  class="slean-table-scroll"
1685
1692
  data-page-sticky={fits || undefined}
1693
+ data-head-follows={(stickyHeader && !height && !fits && !scrollsY) || undefined}
1694
+ style:--slean-table-travel={stickyHeader && !height && !fits && !scrollsY
1695
+ ? `${travel}px`
1696
+ : undefined}
1686
1697
  style:max-height={height}
1687
1698
  tabindex={height ? 0 : undefined}
1688
1699
  role="region"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svelte-lean/table",
3
- "version": "0.13.1",
3
+ "version": "0.13.3",
4
4
  "description": "A Svelte-native table and data-grid engine that ships only the features you use.",
5
5
  "license": "MIT",
6
6
  "author": "Ömer Say",