@xwadex/fesd-next 0.3.4-7.5 → 0.3.4-7.6
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/useAnchors.d.ts +13 -16
- package/dist/hooks/useAnchors.js +27 -25
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Easing } from "motion/react";
|
|
2
2
|
export interface PropsTypes {
|
|
3
3
|
}
|
|
4
|
-
export interface
|
|
4
|
+
export interface AnimateOptions {
|
|
5
5
|
duration?: number;
|
|
6
6
|
delay?: number;
|
|
7
7
|
ease?: Easing | Easing[] | undefined;
|
|
@@ -9,7 +9,7 @@ export interface AnimationOptions {
|
|
|
9
9
|
onScrolling?: (value: number) => void;
|
|
10
10
|
onScrolled?: () => void;
|
|
11
11
|
}
|
|
12
|
-
export interface
|
|
12
|
+
export interface AnchorOptions extends AnimateOptions {
|
|
13
13
|
anchor: string;
|
|
14
14
|
container?: string;
|
|
15
15
|
offseters?: string | string[];
|
|
@@ -17,7 +17,7 @@ export interface AnchorActionsOptions extends AnimationOptions {
|
|
|
17
17
|
align?: "start" | "center" | "end";
|
|
18
18
|
offset?: number;
|
|
19
19
|
}
|
|
20
|
-
export interface
|
|
20
|
+
export interface ScrollOptions extends AnimateOptions {
|
|
21
21
|
containerDom: HTMLElement | Window;
|
|
22
22
|
scrollValue: {
|
|
23
23
|
x: number;
|
|
@@ -27,22 +27,22 @@ export interface ScrollAnimationsOptions extends AnimationOptions {
|
|
|
27
27
|
left: number;
|
|
28
28
|
top: number;
|
|
29
29
|
};
|
|
30
|
-
direction?:
|
|
30
|
+
direction?: AnchorOptions["direction"];
|
|
31
31
|
}
|
|
32
32
|
export declare function useAnchors(): {
|
|
33
33
|
registerAnchors: typeof registerAnchors;
|
|
34
34
|
registerContainers: typeof registerContainers;
|
|
35
35
|
registerOffseters: typeof registerOffseters;
|
|
36
|
-
setStores: (
|
|
36
|
+
setStores: (states: AnchorStoreStates) => void;
|
|
37
37
|
getStores: () => AnchorsStores;
|
|
38
|
-
scrollToAnchor: (anchorOptions:
|
|
38
|
+
scrollToAnchor: (anchorOptions: AnchorOptions) => void;
|
|
39
39
|
};
|
|
40
|
-
export interface
|
|
41
|
-
name: string;
|
|
40
|
+
export interface RegistrationDatas {
|
|
42
41
|
key: keyof AnchorsStores;
|
|
42
|
+
name: string;
|
|
43
43
|
node: HTMLDivElement | null;
|
|
44
44
|
}
|
|
45
|
-
export declare function registration({ name, key, node }:
|
|
45
|
+
export declare function registration({ name, key, node }: RegistrationDatas): void;
|
|
46
46
|
export declare function registerAnchors(name: string): {
|
|
47
47
|
ref: (node: HTMLDivElement | null) => void;
|
|
48
48
|
"data-anchor": string;
|
|
@@ -55,17 +55,14 @@ export declare function registerOffseters(name: string): {
|
|
|
55
55
|
ref: (node: HTMLDivElement | null) => void;
|
|
56
56
|
"data-anchor-offseter": string;
|
|
57
57
|
};
|
|
58
|
-
export
|
|
58
|
+
export interface AnchorsStores {
|
|
59
59
|
anchors: Map<string, HTMLElement | null>;
|
|
60
60
|
containers: Map<string, HTMLElement | null>;
|
|
61
61
|
offseters: Map<string, HTMLElement | null>;
|
|
62
|
-
}
|
|
62
|
+
}
|
|
63
63
|
export declare const useAnchorsStores: import("zustand").UseBoundStore<import("zustand").StoreApi<AnchorsStores>>;
|
|
64
64
|
export declare const getAnchorsStores: () => AnchorsStores;
|
|
65
|
-
export interface
|
|
66
|
-
key: keyof AnchorsStores;
|
|
65
|
+
export interface AnchorStoreStates extends RegistrationDatas {
|
|
67
66
|
action: "add" | "remove";
|
|
68
|
-
name: string;
|
|
69
|
-
node?: HTMLElement | null;
|
|
70
67
|
}
|
|
71
|
-
export declare const setAnchorStore: (
|
|
68
|
+
export declare const setAnchorStore: (states: AnchorStoreStates) => void;
|
package/dist/hooks/useAnchors.js
CHANGED
|
@@ -138,28 +138,30 @@ export const useAnchorsStores = create()(() => ({
|
|
|
138
138
|
offseters: new Map(),
|
|
139
139
|
}));
|
|
140
140
|
export const getAnchorsStores = () => useAnchorsStores.getState();
|
|
141
|
-
export const setAnchorStore = (
|
|
142
|
-
const { key, action, name, node } =
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
141
|
+
export const setAnchorStore = (states) => {
|
|
142
|
+
const { key, action, name, node } = states;
|
|
143
|
+
useAnchorsStores.setState(stores => {
|
|
144
|
+
switch (key) {
|
|
145
|
+
case "anchors":
|
|
146
|
+
if (action == "add" && node instanceof HTMLElement)
|
|
147
|
+
stores.anchors?.set(name, node);
|
|
148
|
+
if (action == "remove")
|
|
149
|
+
stores.anchors?.delete(name);
|
|
150
|
+
return { anchors: stores.anchors };
|
|
151
|
+
case "containers":
|
|
152
|
+
if (action == "add" && node instanceof HTMLElement)
|
|
153
|
+
stores.containers?.set(name, node);
|
|
154
|
+
if (action == "remove")
|
|
155
|
+
stores.containers?.delete(name);
|
|
156
|
+
return { containers: stores.containers };
|
|
157
|
+
case "offseters":
|
|
158
|
+
if (action == "add" && node instanceof HTMLElement)
|
|
159
|
+
stores.offseters?.set(name, node);
|
|
160
|
+
if (action == "remove")
|
|
161
|
+
stores.offseters?.delete(name);
|
|
162
|
+
return { offseters: stores.offseters };
|
|
163
|
+
default:
|
|
164
|
+
return stores;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
};
|