@sharadox/scroll-web-library 0.4.1 → 0.5.0-development.11
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 +9 -8
- package/distribution/glide-into-view/index.d.ts +11 -0
- package/distribution/glide-into-view/index.d.ts.map +1 -0
- package/distribution/glide-into-view/index.js +16 -0
- package/distribution/glide-into-view/index.js.map +1 -0
- package/distribution/glide-into-view/type.d.ts +7 -0
- package/distribution/glide-into-view/type.d.ts.map +1 -0
- package/distribution/glide-into-view/type.js +2 -0
- package/distribution/glide-into-view/type.js.map +1 -0
- package/distribution/smooth-scroll/index.d.ts +4 -1
- package/distribution/smooth-scroll/index.d.ts.map +1 -1
- package/distribution/smooth-scroll/index.js +34 -5
- package/distribution/smooth-scroll/index.js.map +1 -1
- package/llms.txt +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Scrolling for React websites:
|
|
4
4
|
|
|
5
5
|
- **Smooth scrolling:** inertial scrolling with Lenis, including in-page anchor links that stop above a fixed header. A link to the page already open (the logo on the home page) glides back to the top instead of reloading. Smoothing turns off for visitors who prefer reduced motion; same-page links still skip the reload.
|
|
6
|
-
- **Glide:** `glideTo(top)` moves the page through the smooth scrolling, so code-driven moves ease like the visitor's own.
|
|
6
|
+
- **Glide:** `glideTo(top)` moves the page through the smooth scrolling, so code-driven moves ease like the visitor's own. `glideIntoView(element)` brings an element into view, clear of the top bar, when it isn't wholly in view (a form's thank-you after sending on a phone).
|
|
7
7
|
- **Scroll steps:** `useScrollSteps(section, count)` gives a tall pinned section that shows steps one after another (a timelapse, a story) one step per scroll gesture: one wheel turn, trackpad swipe or finger swipe. It doesn't take many to get from one step to the next.
|
|
8
8
|
- **Active section:** which section holds the middle of the screen, how far through it you are, and how far down the page. That's what section indicators and progress bars need.
|
|
9
9
|
|
|
@@ -15,13 +15,14 @@ pnpm add @sharadox/scroll-web-library
|
|
|
15
15
|
|
|
16
16
|
## API
|
|
17
17
|
|
|
18
|
-
| Import
|
|
19
|
-
|
|
|
20
|
-
| `…/smooth-scroll`
|
|
21
|
-
| `…/section-link`
|
|
22
|
-
| `…/active-section`
|
|
23
|
-
| `…/glide`
|
|
24
|
-
| `…/
|
|
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; in a page or a layout, and a glide from one page never carries over to the next) |
|
|
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
|
+
| `…/glide-into-view` | `glideIntoView(element, { offset? = 96, duration? })`: glides the element's top to `offset` below the window's top when it isn't wholly in view |
|
|
25
|
+
| `…/scroll-steps` | `useScrollSteps(sectionRef, count, { duration? })` (0.9 s by default) |
|
|
25
26
|
|
|
26
27
|
## Develop
|
|
27
28
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GlideIntoViewOptions } from "@sharadox/scroll-web-library/glide-into-view/type";
|
|
2
|
+
/**
|
|
3
|
+
* Brings an element into view when it isn't wholly in view already: the page glides (through the smooth scrolling,
|
|
4
|
+
* like every other move) until the element's top sits `offset` pixels below the top of the window, clear of a fixed
|
|
5
|
+
* bar. For something that appears in place of something taller, such as a form's thank-you after sending on a phone.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <div ref={(element) => element && glideIntoView(element)}>Thank you</div>
|
|
9
|
+
*/
|
|
10
|
+
export declare function glideIntoView(element: Element, { offset, duration }?: GlideIntoViewOptions): void;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/glide-into-view/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AAE9F;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,MAAW,EAAE,QAAQ,EAAE,GAAE,oBAAyB,QAInG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { glideTo } from "@sharadox/scroll-web-library/glide";
|
|
2
|
+
/**
|
|
3
|
+
* Brings an element into view when it isn't wholly in view already: the page glides (through the smooth scrolling,
|
|
4
|
+
* like every other move) until the element's top sits `offset` pixels below the top of the window, clear of a fixed
|
|
5
|
+
* bar. For something that appears in place of something taller, such as a form's thank-you after sending on a phone.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <div ref={(element) => element && glideIntoView(element)}>Thank you</div>
|
|
9
|
+
*/
|
|
10
|
+
export function glideIntoView(element, { offset = 96, duration } = {}) {
|
|
11
|
+
const box = element.getBoundingClientRect();
|
|
12
|
+
if (box.top >= offset && box.bottom <= innerHeight)
|
|
13
|
+
return;
|
|
14
|
+
glideTo(Math.max(0, box.top + scrollY - offset), duration === undefined ? {} : { duration });
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/glide-into-view/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAG7D;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,OAAgB,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,QAAQ,KAA2B,EAAE;IAClG,MAAM,GAAG,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAC5C,IAAI,GAAG,CAAC,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,WAAW;QAAE,OAAO;IAC3D,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,OAAO,GAAG,MAAM,CAAC,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC/F,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface GlideIntoViewOptions {
|
|
2
|
+
/** The room kept above the element, for a fixed bar at the top: 96 pixels by default. */
|
|
3
|
+
offset?: number;
|
|
4
|
+
/** How long the glide takes, in seconds (with smooth scrolling). */
|
|
5
|
+
duration?: number;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/glide-into-view/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/glide-into-view/type.ts"],"names":[],"mappings":""}
|
|
@@ -3,7 +3,10 @@ import type { SmoothScrollProperties } from "@sharadox/scroll-web-library/smooth
|
|
|
3
3
|
* Smooth, inertial page scrolling, including in-page anchor links (plain ones and `SectionLink`s) and `#top`, which
|
|
4
4
|
* glides to the top of whatever page is open. A link to the page already open (the logo on the home page, for one)
|
|
5
5
|
* glides back to the top instead of reloading. Smoothing is off when the visitor prefers reduced motion: anchors then
|
|
6
|
-
* jump, and the same-page link still goes to the top without reloading.
|
|
6
|
+
* jump, and the same-page link still goes to the top without reloading. It works in a page or in a layout. A page's smoothing stops as soon as the
|
|
7
|
+
* address is another page's, and only one page smooths at a time; a new page leaves the wheel and touch alone for a moment while
|
|
8
|
+
* Next.js places it. So a glide still under way from the previous page (a trackpad's momentum, say) can't send the new
|
|
9
|
+
* page to the old page's place.
|
|
7
10
|
*/
|
|
8
11
|
export declare function SmoothScroll({ duration, anchorOffset }: SmoothScrollProperties): null;
|
|
9
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/smooth-scroll/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/smooth-scroll/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAC;AAc9F;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAe,EAAE,YAAkB,EAAE,EAAE,sBAAsB,QAqE3F"}
|
|
@@ -1,23 +1,44 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import Lenis from "lenis";
|
|
3
|
+
import { usePathname } from "next/navigation";
|
|
3
4
|
import { useEffect } from "react";
|
|
4
5
|
import { registerGlider } from "@sharadox/scroll-web-library/glide";
|
|
6
|
+
/** Milliseconds after a page opens while Next.js places it (at the top, an anchor or where it was). */
|
|
7
|
+
const SETTLING = 300;
|
|
8
|
+
/**
|
|
9
|
+
* Stops the smoothing of the page that came before. Next.js may keep that page a moment after the new one appears; its
|
|
10
|
+
* smoothing must not go on moving the new page towards where the old one was headed.
|
|
11
|
+
*/
|
|
12
|
+
let stopPrevious = null;
|
|
5
13
|
/** A path without its trailing slash, so "/en/" and "/en" count as the same page. */
|
|
6
14
|
const page = (path) => path.replace(/(.)\/$/, "$1");
|
|
7
15
|
/**
|
|
8
16
|
* Smooth, inertial page scrolling, including in-page anchor links (plain ones and `SectionLink`s) and `#top`, which
|
|
9
17
|
* glides to the top of whatever page is open. A link to the page already open (the logo on the home page, for one)
|
|
10
18
|
* glides back to the top instead of reloading. Smoothing is off when the visitor prefers reduced motion: anchors then
|
|
11
|
-
* jump, and the same-page link still goes to the top without reloading.
|
|
19
|
+
* jump, and the same-page link still goes to the top without reloading. It works in a page or in a layout. A page's smoothing stops as soon as the
|
|
20
|
+
* address is another page's, and only one page smooths at a time; a new page leaves the wheel and touch alone for a moment while
|
|
21
|
+
* Next.js places it. So a glide still under way from the previous page (a trackpad's momentum, say) can't send the new
|
|
22
|
+
* page to the old page's place.
|
|
12
23
|
*/
|
|
13
24
|
export function SmoothScroll({ duration = 1.15, anchorOffset = -60 }) {
|
|
25
|
+
// In a layout, it stays mounted from page to page: each page gets smoothing of its own.
|
|
26
|
+
const pathname = usePathname();
|
|
14
27
|
useEffect(() => {
|
|
28
|
+
stopPrevious?.();
|
|
29
|
+
// While the page is being placed, wheel and touch events still belong to the previous page's gesture; once the
|
|
30
|
+
// address is another page's (a link, or back and forward), this page's smoothing has nothing more to do.
|
|
31
|
+
const opened = performance.now();
|
|
32
|
+
const path = page(location.pathname);
|
|
33
|
+
const here = () => page(location.pathname) === path;
|
|
34
|
+
const listening = () => here() && performance.now() - opened >= SETTLING;
|
|
15
35
|
const lenis = window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
|
16
36
|
? null
|
|
17
|
-
: new Lenis({ duration, smoothWheel: true });
|
|
37
|
+
: new Lenis({ duration, smoothWheel: true, virtualScroll: listening });
|
|
18
38
|
let frame = 0;
|
|
19
39
|
const animate = (time) => {
|
|
20
|
-
|
|
40
|
+
if (here())
|
|
41
|
+
lenis.raf(time);
|
|
21
42
|
frame = requestAnimationFrame(animate);
|
|
22
43
|
};
|
|
23
44
|
if (lenis)
|
|
@@ -65,13 +86,21 @@ export function SmoothScroll({ duration = 1.15, anchorOffset = -60 }) {
|
|
|
65
86
|
}
|
|
66
87
|
};
|
|
67
88
|
document.addEventListener("click", onClick);
|
|
68
|
-
|
|
89
|
+
const stop = () => {
|
|
69
90
|
cancelAnimationFrame(frame);
|
|
70
91
|
document.removeEventListener("click", onClick);
|
|
71
92
|
lenis?.destroy();
|
|
93
|
+
};
|
|
94
|
+
stopPrevious = stop;
|
|
95
|
+
return () => {
|
|
96
|
+
// Already stopped (and replaced) if a newer page took over; otherwise this page is the one leaving.
|
|
97
|
+
if (stopPrevious !== stop)
|
|
98
|
+
return;
|
|
99
|
+
stop();
|
|
100
|
+
stopPrevious = null;
|
|
72
101
|
registerGlider(null);
|
|
73
102
|
};
|
|
74
|
-
}, [duration, anchorOffset]);
|
|
103
|
+
}, [duration, anchorOffset, pathname]);
|
|
75
104
|
return null;
|
|
76
105
|
}
|
|
77
106
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/smooth-scroll/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGpE,qFAAqF;AACrF,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAE5D
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/smooth-scroll/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGpE,uGAAuG;AACvG,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB;;;GAGG;AACH,IAAI,YAAY,GAAwB,IAAI,CAA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AAQ,CAAC,CAAC,CAAC;IACvC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/llms.txt
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
- /smooth-scroll: <SmoothScroll duration=1.15 anchorOffset=-60 /> — off with prefers-reduced-motion; handles a[href^="#"] clicks
|
|
6
6
|
- /active-section: useActiveSection(ids: readonly string[]) → { active: id at viewport middle, within: 0–1 through it, page: 0–1 page progress }
|
|
7
7
|
- Peer: react. License: Sharadox Open Source License 0.1.0
|
|
8
|
+
- SmoothScroll works in a page or a layout (it starts afresh for every pathname). Each page's smoothing stops the moment the address is another page's (link, back or forward) and a new page stops the previous one's, so a glide or trackpad momentum from the old page never moves the new one; for 300 ms after a page opens, wheel and touch are left to the browser while Next.js places it (0.4.2).
|
|
8
9
|
- SmoothScroll also turns plain clicks on links to the current page (same path, no hash or query, no target, no modifier keys) into a scroll to the top, without reloading — with or without reduced motion.
|
|
9
10
|
- /glide: glideTo(top, { duration? }) — through the running SmoothScroll (Lenis) or window.scrollTo (smooth, or auto with reduced motion); registerGlider is internal to SmoothScroll
|
|
11
|
+
- /glide-into-view: glideIntoView(element, { offset? = 96, duration? }) — glides the element's top to offset below the window's top, only when it isn't wholly in view (0.5.0)
|
|
10
12
|
- /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
13
|
- 0.3.0: glide, scroll-steps
|
|
12
14
|
- 0.3.1: a finger swipe's step glide starts after the touch event, so smooth scrolling (Lenis) no longer stops it on phones
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sharadox/scroll-web-library",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-development.11",
|
|
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",
|