@motion-proto/live-tokens 0.37.0 → 0.38.0

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,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.38.0 — Overridable scroll reset for smooth-scroll hosts
4
+
5
+ ### Added
6
+
7
+ - **`setScrollReset(fn)` lets a host route navigation's scroll reset through its
8
+ own scroll system.** On a non-hash `navigate()` the router resets the viewport
9
+ to the top. That default calls `window.scrollTo(0, 0)`, which is invisible to
10
+ consumers driving scroll with a smooth-scroll library (Lenis, Locomotive):
11
+ their scroll position is decoupled from the window, so the rendered page stays
12
+ put — most visibly when `LiveTokensRouter` intercepts an in-page link (e.g. a
13
+ card) and the new page opens mid-scroll instead of at the top. Register a reset
14
+ that drives your provider (`setScrollReset(() => lenis.scrollTo(0, { immediate: true }))`)
15
+ and both the overlay's nav and intercepted links reset correctly. Hash targets
16
+ still skip the reset so in-page anchors are unaffected. Backward compatible —
17
+ unset, the native `window.scrollTo` behavior is unchanged.
18
+
3
19
  ## 0.37.0 — ImageLightbox `capNatural` accepts a multiple
4
20
 
5
21
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motion-proto/live-tokens",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "type": "module",
5
5
  "description": "Design token editor with live CSS variable editing. Svelte 5 + Vite 8.",
6
6
  "keywords": [
@@ -13,6 +13,17 @@ function rememberPrev(current: string) {
13
13
 
14
14
  export const route = writable<string>('/');
15
15
 
16
+ // Scroll reset on navigation. The default jumps the native viewport to the top,
17
+ // which is invisible to consumers that drive scrolling with a smooth-scroll
18
+ // library (Lenis, Locomotive): their internal scroll position is decoupled from
19
+ // the window, so `window.scrollTo` leaves the rendered page where it was.
20
+ // `setScrollReset` lets such hosts route the reset through their own provider.
21
+ let scrollReset = () => window.scrollTo(0, 0);
22
+
23
+ export function setScrollReset(fn: () => void) {
24
+ scrollReset = fn;
25
+ }
26
+
16
27
  let initialised = false;
17
28
 
18
29
  /**
@@ -43,7 +54,7 @@ export function navigate(path: string) {
43
54
  rememberPrev(window.location.pathname || '/');
44
55
  history.pushState(null, '', path);
45
56
  if (!path.includes('#')) {
46
- window.scrollTo(0, 0);
57
+ scrollReset();
47
58
  }
48
59
  }
49
60
  route.set(pathname);
@@ -9,7 +9,7 @@ export type { BootLiveTokensOptions } from './bootstrap';
9
9
  export { columnsVisible, toggleColumns, init as initColumnsOverlay } from './overlay/columnsOverlay';
10
10
  export { configureEditor, storageKey } from './core/store/editorConfig';
11
11
  export { activeFileName } from './core/store/editorConfigStore';
12
- export { init as initRouter, route, navigate } from './core/routing/router';
12
+ export { init as initRouter, route, navigate, setScrollReset } from './core/routing/router';
13
13
  export { init as initCssVarSync } from './core/cssVarSync';
14
14
  export {
15
15
  init as initEditorStore,