@sharadox/scroll-web-library 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/README.md CHANGED
@@ -15,13 +15,13 @@ pnpm add @sharadox/scroll-web-library
15
15
 
16
16
  ## API
17
17
 
18
- | Import | Export |
19
- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
20
- | `…/smooth-scroll` | `<SmoothScroll duration? anchorOffset?>` (renders nothing; default 1.15 s and -60 px; `#top` glides to the top of any page) |
21
- | `…/section-link` | `<SectionLink href>`: Next.js `Link` for a section (`#id`, `/en#id`) that leaves scrolling to `SmoothScroll` (`scroll={false}`) |
22
- | `…/active-section` | `useActiveSection(ids)` → `{ active, within, page }` (keep `ids` stable, for example a module constant) |
23
- | `…/glide` | `glideTo(top, { duration? })` |
24
- | `…/scroll-steps` | `useScrollSteps(sectionRef, count, { duration? })` (0.9 s by default) |
18
+ | Import | Export |
19
+ | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
20
+ | `…/smooth-scroll` | `<SmoothScroll duration? anchorOffset?>` (renders nothing; default 1.15 s and -60 px; `#top` glides to the top of any page) |
21
+ | `…/section-link` | `<SectionLink href>`: Next.js `Link` for a section: on this page (`#id`) scrolling is left to `SmoothScroll` (`scroll={false}`); on another page (`/en#id`) Next.js scrolls there |
22
+ | `…/active-section` | `useActiveSection(ids)` → `{ active, within, page }` (keep `ids` stable, for example a module constant) |
23
+ | `…/glide` | `glideTo(top, { duration? })` |
24
+ | `…/scroll-steps` | `useScrollSteps(sectionRef, count, { duration? })` (0.9 s by default) |
25
25
 
26
26
  ## Develop
27
27
 
@@ -1,11 +1,13 @@
1
1
  import Link from "next/link";
2
2
  import type { ComponentProps } from "react";
3
3
  /**
4
- * Next.js `Link` for a section of the page (`#contact`, or `/en#contact` from another page). Next.js updates the address
5
- * and `SmoothScroll` does the scrolling (`scroll={false}`), so the page glides there instead of two scrolls fighting.
4
+ * Next.js `Link` for a section of a page. For one on this page (`#contact`), Next.js updates the address and
5
+ * `SmoothScroll` does the scrolling (`scroll={false}`), so the page glides there instead of two scrolls fighting. For
6
+ * one on another page (`/en#contact`), Next.js goes to that page and scrolls to the section itself, as `Link` does.
6
7
  *
7
8
  * @example
8
9
  * <SectionLink href="#contact">Contact</SectionLink>
10
+ * <SectionLink href="/en#contact">Contact</SectionLink>
9
11
  */
10
12
  export declare function SectionLink(properties: ComponentProps<typeof Link>): import("react").JSX.Element;
11
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/section-link/index.tsx"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,cAAc,CAAC,OAAO,IAAI,CAAC,+BAElE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/section-link/index.tsx"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,cAAc,CAAC,OAAO,IAAI,CAAC,+BAGlE"}
@@ -1,13 +1,16 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import Link from "next/link";
3
3
  /**
4
- * Next.js `Link` for a section of the page (`#contact`, or `/en#contact` from another page). Next.js updates the address
5
- * and `SmoothScroll` does the scrolling (`scroll={false}`), so the page glides there instead of two scrolls fighting.
4
+ * Next.js `Link` for a section of a page. For one on this page (`#contact`), Next.js updates the address and
5
+ * `SmoothScroll` does the scrolling (`scroll={false}`), so the page glides there instead of two scrolls fighting. For
6
+ * one on another page (`/en#contact`), Next.js goes to that page and scrolls to the section itself, as `Link` does.
6
7
  *
7
8
  * @example
8
9
  * <SectionLink href="#contact">Contact</SectionLink>
10
+ * <SectionLink href="/en#contact">Contact</SectionLink>
9
11
  */
10
12
  export function SectionLink(properties) {
11
- return _jsx(Link, { scroll: false, ...properties });
13
+ const here = typeof properties.href === "string" && properties.href.startsWith("#");
14
+ return _jsx(Link, { ...(here ? { scroll: false } : {}), ...properties });
12
15
  }
13
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/section-link/index.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,UAAuC;IACjE,OAAO,KAAC,IAAI,IAAC,MAAM,EAAE,KAAK,KAAM,UAAU,GAAI,CAAC;AACjD,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/section-link/index.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,UAAuC;IACjE,MAAM,IAAI,GAAG,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACpF,OAAO,KAAC,IAAI,OAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAM,UAAU,GAAI,CAAC;AACvE,CAAC"}
package/llms.txt CHANGED
@@ -10,5 +10,6 @@
10
10
  - /scroll-steps: useScrollSteps(sectionRef, count, { duration? = 0.9 }) — while the section is pinned, each wheel gesture (a pause of 180 ms starts a new one) or finger swipe (30 px+) glides exactly one step; step i sits at top + (i + 0.5) / count × (height − innerHeight); past the ends the page scrolls on
11
11
  - 0.3.0: glide, scroll-steps
12
12
  - 0.3.1: a finger swipe's step glide starts after the touch event, so smooth scrolling (Lenis) no longer stops it on phones
13
- - /section-link: <SectionLink href …LinkProps> — next/link with scroll={false} for in-page sections; SmoothScroll glides (or, with reduced motion, jumps) to the anchor even though Link took the click
13
+ - /section-link: <SectionLink href …LinkProps> — next/link; for "#id" on this page scroll={false} (SmoothScroll glides), for "/path#id" Next.js navigates and scrolls as usual; SmoothScroll glides (or, with reduced motion, jumps) to the anchor even though Link took the click
14
14
  - 0.4.0: SectionLink; SmoothScroll handles "#top" (top of the open page) and anchors whose click a Next.js Link already took; next is a peer dependency
15
+ - 0.4.1: SectionLink leaves Next.js scrolling on for sections of other pages ("/en#contact"), so they land on the section
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sharadox/scroll-web-library",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Scrolling for React websites: smooth inertial scrolling with anchor jumps (Lenis) and the active section with page progress.",
5
5
  "private": false,
6
6
  "license": "SEE LICENSE IN LICENCA.md",