@sharadox/scroll-web-library 0.7.0 → 0.7.1-development.30
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 +4 -0
- package/README.md +9 -9
- package/distribution/smooth-scroll/index.d.ts +0 -1
- package/distribution/smooth-scroll/index.d.ts.map +1 -1
- package/distribution/smooth-scroll/index.js +0 -1
- package/distribution/smooth-scroll/index.js.map +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/distribution/smooth-scroll/index.css +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
What changed in each version of `@sharadox/scroll-web-library`, newest first.
|
|
4
4
|
|
|
5
|
+
## 0.7.1
|
|
6
|
+
|
|
7
|
+
SmoothScroll no longer imports its page CSS: a global stylesheet imported from a library changed the order Next.js loads a site's styles in (the Sharadox home page moved by 16 pixels in its visual tests). Sites keep those few rules in their own global stylesheet.
|
|
8
|
+
|
|
5
9
|
## 0.7.0
|
|
6
10
|
|
|
7
11
|
SmoothScroll brings the page CSS Lenis needs (html.lenis heights, no browser smoothing while it runs, nothing scrolls while stopped), so sites drop their copies; built with library-build so the stylesheet ships; useScrolledPast; current library versions
|
package/README.md
CHANGED
|
@@ -15,15 +15,15 @@ pnpm add @sharadox/scroll-web-library
|
|
|
15
15
|
|
|
16
16
|
## API
|
|
17
17
|
|
|
18
|
-
| Import | Export
|
|
19
|
-
| ------------------- |
|
|
20
|
-
| `…/scrolled-past` | `useScrolledPast(point)`: whether the page has scrolled past a distance (or a share of the window's height), kept up to date
|
|
21
|
-
| `…/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;
|
|
22
|
-
| `…/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
|
|
23
|
-
| `…/active-section` | `useActiveSection(ids)` → `{ active, within, page }` (keep `ids` stable, for example a module constant)
|
|
24
|
-
| `…/glide` | `glideTo(top, { duration? })`
|
|
25
|
-
| `…/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
|
|
26
|
-
| `…/scroll-steps` | `useScrollSteps(sectionRef, count, { duration? })` (0.9 s by default)
|
|
18
|
+
| Import | Export |
|
|
19
|
+
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
20
|
+
| `…/scrolled-past` | `useScrolledPast(point)`: whether the page has scrolled past a distance (or a share of the window's height), kept up to date |
|
|
21
|
+
| `…/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; the page CSS smooth scrolling needs (`html.lenis, html.lenis body { height: auto }`, `.lenis.lenis-smooth { scroll-behavior: auto !important }`, `.lenis.lenis-stopped { overflow: hidden }`) stays in the site's global stylesheet: a stylesheet imported from a library changes the order Next.js loads the site's styles in) |
|
|
22
|
+
| `…/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 |
|
|
23
|
+
| `…/active-section` | `useActiveSection(ids)` → `{ active, within, page }` (keep `ids` stable, for example a module constant) |
|
|
24
|
+
| `…/glide` | `glideTo(top, { duration? })` |
|
|
25
|
+
| `…/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 |
|
|
26
|
+
| `…/scroll-steps` | `useScrollSteps(sectionRef, count, { duration? })` (0.9 s by default) |
|
|
27
27
|
|
|
28
28
|
## Develop
|
|
29
29
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { SmoothScrollProperties } from "@sharadox/scroll-web-library/smooth-scroll/type";
|
|
2
|
-
import "./index.css";
|
|
3
2
|
/**
|
|
4
3
|
* Smooth, inertial page scrolling, including in-page anchor links (plain ones and `SectionLink`s) and `#top`, which
|
|
5
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)
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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"}
|
|
@@ -3,7 +3,6 @@ import Lenis from "lenis";
|
|
|
3
3
|
import { usePathname } from "next/navigation";
|
|
4
4
|
import { useEffect } from "react";
|
|
5
5
|
import { registerGlider } from "@sharadox/scroll-web-library/glide";
|
|
6
|
-
import "./index.css";
|
|
7
6
|
/** Milliseconds after a page opens while Next.js places it (at the top, an anchor or where it was). */
|
|
8
7
|
const SETTLING = 300;
|
|
9
8
|
/**
|
|
@@ -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,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":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C,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/C,KAAK,EAAE,OAAO,EAAE,CAAC;QACnB,CAAC,CAAC;QACF,YAAY,GAAG,IAAI,CAAC;QACpB,OAAO,GAAG,EAAE;YACV,oGAAoG;YACpG,IAAI,YAAY,KAAK,IAAI;gBAAE,OAAO;YAClC,IAAI,EAAE,CAAC;YACP,YAAY,GAAG,IAAI,CAAC;YACpB,cAAc,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;IACvC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/llms.txt
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> Smooth scrolling (Lenis) and active-section tracking for React.
|
|
4
4
|
|
|
5
5
|
- /scrolled-past: useScrolledPast(point: px | (windowHeight) => px) → boolean, kept up to date on scroll and resize (a bar that turns solid, an action that appears below the hero)
|
|
6
|
-
- /smooth-scroll: <SmoothScroll duration=1.15 anchorOffset=-60 /> — off with prefers-reduced-motion; handles a[href^="#"] clicks;
|
|
6
|
+
- /smooth-scroll: <SmoothScroll duration=1.15 anchorOffset=-60 /> — off with prefers-reduced-motion; handles a[href^="#"] clicks; sites keep the page CSS Lenis needs in their own global stylesheet (a stylesheet imported from a library changes the order Next.js loads the site's styles in)
|
|
7
7
|
- /active-section: useActiveSection(ids: readonly string[]) → { active: id at viewport middle, within: 0–1 through it, page: 0–1 page progress }
|
|
8
8
|
- Peer: react. License: Sharadox Open Source License 0.1.0
|
|
9
9
|
- 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).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sharadox/scroll-web-library",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1-development.30",
|
|
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",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/* What Lenis (the smooth scrolling) needs from the page: it moves the page itself, so the browser's own smoothing
|
|
2
|
-
stays off while it runs, and nothing scrolls while it's stopped (a menu or a viewer is open). */
|
|
3
|
-
html.lenis,
|
|
4
|
-
html.lenis body {
|
|
5
|
-
height: auto;
|
|
6
|
-
}
|
|
7
|
-
.lenis.lenis-smooth {
|
|
8
|
-
scroll-behavior: auto !important;
|
|
9
|
-
}
|
|
10
|
-
.lenis.lenis-stopped {
|
|
11
|
-
overflow: hidden;
|
|
12
|
-
}
|