@xwadex/fesd-next 0.3.4-7.1 → 0.3.4-7.3
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/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -22,7 +22,7 @@ export declare function useAnchors(): {
|
|
|
22
22
|
removeAnchor: (name: string) => void;
|
|
23
23
|
removeOffseter: (name: string) => void;
|
|
24
24
|
removeContainer: (name: string) => void;
|
|
25
|
-
scrollToAnchor: ({ anchor: anchorName, container: containerName, ...
|
|
25
|
+
scrollToAnchor: ({ anchor: anchorName, container: containerName, ...anchorOptions }: AnchorActionsOptions) => void;
|
|
26
26
|
};
|
|
27
27
|
export declare function registerAnchors(name: string): {
|
|
28
28
|
ref: (node: HTMLDivElement | null) => void;
|
package/dist/hooks/useAnchors.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
// update: 2025.10.29
|
|
3
|
+
// version: 0.0.1
|
|
4
|
+
// dev: wade
|
|
2
5
|
import { useCallback, useMemo, useRef } from "react";
|
|
3
6
|
import { animate, useMotionValue } from "motion/react";
|
|
4
7
|
import { create } from "zustand";
|
|
5
8
|
export function useAnchors() {
|
|
6
9
|
const motionValue = useMotionValue(0);
|
|
7
10
|
const controlsRef = useRef(null);
|
|
8
|
-
const scrollToAnchor = useCallback(({ anchor: anchorName, container: containerName, ...
|
|
9
|
-
const { offseters, direction = "vertical",
|
|
11
|
+
const scrollToAnchor = useCallback(({ anchor: anchorName, container: containerName, ...anchorOptions }) => {
|
|
12
|
+
const { offseters, direction = "vertical", onScroll, onScrolling, onScrolled, ...options } = anchorOptions;
|
|
10
13
|
if (!anchorName || !containerName)
|
|
11
14
|
return;
|
|
12
15
|
const stores = getAnchorsStores();
|
|
@@ -29,15 +32,13 @@ export function useAnchors() {
|
|
|
29
32
|
// console.log(scrollOffset == containerScrollTop);
|
|
30
33
|
motionValue.set(containerScrollTop);
|
|
31
34
|
controlsRef.current = animate(motionValue, scrollOffset, {
|
|
32
|
-
duration: 0.5,
|
|
33
|
-
delay: 5,
|
|
34
|
-
ease: [0.215, 0.61, 0.355, 1.0],
|
|
35
35
|
onPlay: onScroll,
|
|
36
36
|
onComplete: onScrolled,
|
|
37
37
|
onUpdate: (value) => {
|
|
38
38
|
containerDom.scrollTop = value;
|
|
39
39
|
onScrolling?.(value);
|
|
40
40
|
},
|
|
41
|
+
...options,
|
|
41
42
|
});
|
|
42
43
|
}, [motionValue]);
|
|
43
44
|
const returnsMemo = useMemo(() => ({
|