@sharadox/scroll-web-library 0.5.1-dependency-update.13 → 0.6.0-development.18

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
@@ -17,6 +17,7 @@ pnpm add @sharadox/scroll-web-library
17
17
 
18
18
  | Import | Export |
19
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 |
20
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) |
21
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 |
22
23
  | `…/active-section` | `useActiveSection(ids)` → `{ active, within, page }` (keep `ids` stable, for example a module constant) |
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Whether the page has scrolled past a point, kept up to date as it scrolls: a distance in pixels, or a function of
3
+ * the window's height (`(height) => height * 0.6`, past most of the first screen). False until the page has loaded.
4
+ * For a bar that turns solid once the page moves, or an action that appears below the hero.
5
+ *
6
+ * @example
7
+ * const scrolled = useScrolledPast(24);
8
+ */
9
+ export declare function useScrolledPast(point: number | ((windowHeight: number) => number)): boolean;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/scrolled-past/index.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,OAAO,CAa3F"}
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { useEffect, useState } from "react";
3
+ /**
4
+ * Whether the page has scrolled past a point, kept up to date as it scrolls: a distance in pixels, or a function of
5
+ * the window's height (`(height) => height * 0.6`, past most of the first screen). False until the page has loaded.
6
+ * For a bar that turns solid once the page moves, or an action that appears below the hero.
7
+ *
8
+ * @example
9
+ * const scrolled = useScrolledPast(24);
10
+ */
11
+ export function useScrolledPast(point) {
12
+ const [past, setPast] = useState(false);
13
+ useEffect(() => {
14
+ const update = () => setPast(scrollY > (typeof point === "number" ? point : point(innerHeight)));
15
+ update();
16
+ addEventListener("scroll", update, { passive: true });
17
+ addEventListener("resize", update, { passive: true });
18
+ return () => {
19
+ removeEventListener("scroll", update);
20
+ removeEventListener("resize", update);
21
+ };
22
+ }, [point]);
23
+ return past;
24
+ }
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/scrolled-past/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,KAAkD;IAChF,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,GAAG,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACjG,MAAM,EAAE,CAAC;QACT,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,OAAO,GAAG,EAAE;YACV,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACtC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxC,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACZ,OAAO,IAAI,CAAC;AACd,CAAC"}
package/llms.txt CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  > Smooth scrolling (Lenis) and active-section tracking for React.
4
4
 
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)
5
6
  - /smooth-scroll: <SmoothScroll duration=1.15 anchorOffset=-60 /> — off with prefers-reduced-motion; handles a[href^="#"] clicks
6
7
  - /active-section: useActiveSection(ids: readonly string[]) → { active: id at viewport middle, within: 0–1 through it, page: 0–1 page progress }
7
8
  - Peer: react. License: Sharadox Open Source License 0.1.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sharadox/scroll-web-library",
3
- "version": "0.5.1-dependency-update.13",
3
+ "version": "0.6.0-development.18",
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",