@sharadox/scroll-web-library 0.6.1-smooth-scroll-style.24 → 0.7.0-smooth-scroll-style.25
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.css +12 -0
- package/distribution/smooth-scroll/index.d.ts +1 -0
- package/distribution/smooth-scroll/index.d.ts.map +1 -1
- package/distribution/smooth-scroll/index.js +1 -0
- package/distribution/smooth-scroll/index.js.map +1 -1
- package/llms.txt +1 -1
- package/package.json +8 -7
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.0
|
|
6
|
+
|
|
7
|
+
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
|
|
8
|
+
|
|
5
9
|
## 0.4.1
|
|
6
10
|
|
|
7
11
|
SectionLink leaves Next.js scrolling on for sections of other pages ("/en#contact"), so they land on the section
|
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; it brings the page CSS smooth scrolling needs, so sites don't write it) |
|
|
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
|
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SmoothScrollProperties } from "@sharadox/scroll-web-library/smooth-scroll/type";
|
|
2
|
+
import "./index.css";
|
|
2
3
|
/**
|
|
3
4
|
* Smooth, inertial page scrolling, including in-page anchor links (plain ones and `SectionLink`s) and `#top`, which
|
|
4
5
|
* 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,OAAO,aAAa,CAAC;AAcrB;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAe,EAAE,YAAkB,EAAE,EAAE,sBAAsB,QAqE3F"}
|
|
@@ -3,6 +3,7 @@ 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";
|
|
6
7
|
/** Milliseconds after a page opens while Next.js places it (at the top, an anchor or where it was). */
|
|
7
8
|
const SETTLING = 300;
|
|
8
9
|
/**
|
|
@@ -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,CA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CAAC,CAAC;YACrD,CAAC;QACH,CAAC,CAAC;QACF,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5C,MAAM,IAAI,GAAG,GAAG,EAAE;YAChB,oBAAoB,CAAC,KAAK,CAAC,CAAC;YAC5B,QAAQ,CAAC,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; brings the page CSS Lenis needs (sites no longer write it)
|
|
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.
|
|
3
|
+
"version": "0.7.0-smooth-scroll-style.25",
|
|
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",
|
|
@@ -51,9 +51,10 @@
|
|
|
51
51
|
"homepage": "https://github.com/Sharadox/scroll-web-library#readme",
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@sharadox/es-lint-configuration-web-library": "^0.1.1",
|
|
54
|
+
"@sharadox/library-build-web-library": "^0.1.2",
|
|
54
55
|
"@sharadox/prettier-configuration-web-library": "^0.1.0",
|
|
55
56
|
"@sharadox/turborepo-configuration-web-library": "^0.1.0",
|
|
56
|
-
"@sharadox/type-script-configuration-web-library": "^0.2.
|
|
57
|
+
"@sharadox/type-script-configuration-web-library": "^0.2.2",
|
|
57
58
|
"@sharadox/vitest-configuration-web-library": "^0.1.2",
|
|
58
59
|
"@testing-library/dom": "^10.4.2",
|
|
59
60
|
"@testing-library/react": "^16.3.3",
|
|
@@ -65,25 +66,25 @@
|
|
|
65
66
|
"happy-dom": "^21.0.4",
|
|
66
67
|
"husky": "^9.1.7",
|
|
67
68
|
"lint-staged": "^17.6.0",
|
|
69
|
+
"next": "16.4.5",
|
|
68
70
|
"prettier": "^3.10.0",
|
|
69
71
|
"react": "^19.3.1",
|
|
70
72
|
"react-dom": "^19.3.1",
|
|
71
73
|
"turbo": "^2.11.10",
|
|
72
74
|
"typedoc": "^0.28.20",
|
|
73
75
|
"typescript": "6.0.3",
|
|
74
|
-
"vitest": "^5.1.0"
|
|
75
|
-
"next": "16.4.5"
|
|
76
|
+
"vitest": "^5.1.0"
|
|
76
77
|
},
|
|
77
78
|
"dependencies": {
|
|
78
79
|
"@sharadox/web-library": "^0.9.0",
|
|
79
80
|
"lenis": "^1.3.27"
|
|
80
81
|
},
|
|
81
82
|
"peerDependencies": {
|
|
82
|
-
"
|
|
83
|
-
"
|
|
83
|
+
"next": ">=16",
|
|
84
|
+
"react": ">=19"
|
|
84
85
|
},
|
|
85
86
|
"scripts": {
|
|
86
|
-
"build": "
|
|
87
|
+
"build": "library-build",
|
|
87
88
|
"lint": "eslint --max-warnings=0 .",
|
|
88
89
|
"format": "prettier --write .",
|
|
89
90
|
"format:check": "prettier --check .",
|