@rxdrag/website-lib-core 0.0.103 → 0.0.105
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/package.json +5 -5
- package/src/component-logic/index.ts +1 -8
- package/src/global.d.ts +7 -0
- package/src/index.ts +1 -3
- package/src/react/components/BackgroundHlsVideoPlayer.tsx +30 -1
- package/src/react/components/ContactForm/ContactForm.tsx +3 -2
- package/src/react/components/ContactForm/types.ts +1 -0
- package/src/react/components/ProductCard/ProductCta/index.tsx +5 -21
- package/src/react/components/Scroller.tsx +32 -4
- package/src/react/components/Share/socials.tsx +1 -2
- package/src/react/index.ts +1 -2
- package/src/component-logic/collapse.ts +0 -61
- package/src/component-logic/gsap.d.ts +0 -4
- package/src/component-logic/modal.ts +0 -45
- package/src/component-logic/motion.ts +0 -272
- package/src/component-logic/number.ts +0 -45
- package/src/component-logic/popover.ts +0 -51
- package/src/component-logic/tabs.ts +0 -10
- package/src/controller/AnimateController.ts +0 -138
- package/src/controller/AosController.ts +0 -240
- package/src/controller/CollapseController.ts +0 -130
- package/src/controller/FlipController.ts +0 -339
- package/src/controller/ModalController.ts +0 -127
- package/src/controller/NumberController.ts +0 -161
- package/src/controller/OpenableController.ts +0 -367
- package/src/controller/PageLoader.ts +0 -154
- package/src/controller/PopoverController.ts +0 -116
- package/src/controller/TabsController.ts +0 -271
- package/src/controller/applyAnimation.ts +0 -86
- package/src/controller/applyInitialState.ts +0 -79
- package/src/controller/consts.ts +0 -33
- package/src/controller/index.ts +0 -10
- package/src/controller/utils.ts +0 -48
- package/src/motion/consts.ts +0 -428
- package/src/motion/convertToGsapVars.ts +0 -102
- package/src/motion/index.ts +0 -6
- package/src/motion/normalizeAnimation.ts +0 -28
- package/src/motion/normalizeAosAnimation.ts +0 -22
- package/src/motion/normalizePopupAnimation.ts +0 -24
- package/src/motion/types.ts +0 -133
- package/src/react/hooks/index.ts +0 -1
- package/src/react/hooks/useScroll.ts +0 -30
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DATA_TABS,
|
|
3
|
-
DATA_TABS_SELECTION,
|
|
4
|
-
DATA_TABS_TAB,
|
|
5
|
-
DATA_TABS_PANEL,
|
|
6
|
-
DATA_MOTION_SELECTION,
|
|
7
|
-
} from "../component-logic";
|
|
8
|
-
import { AnimationConfig } from "../motion";
|
|
9
|
-
import { applyAnimation } from "./applyAnimation";
|
|
10
|
-
import { EVENT_SELECT, EVENT_UNSELECT } from "./consts";
|
|
11
|
-
import { EventBus, SelectionEvent } from "./OpenableController";
|
|
12
|
-
|
|
13
|
-
export class TabsController {
|
|
14
|
-
private static instances: Record<string, TabsController> = {};
|
|
15
|
-
private doc?: Document;
|
|
16
|
-
protected eventBus = new EventBus();
|
|
17
|
-
protected unmountHandlers: (() => void)[] = [];
|
|
18
|
-
|
|
19
|
-
private constructor(doc?: Document) {
|
|
20
|
-
this.doc = doc;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 获取 TabsController 实例
|
|
25
|
-
* @param key 实例的唯一标识,默认为 "runtime"
|
|
26
|
-
* @param doc 文档对象
|
|
27
|
-
* @returns TabsController 实例
|
|
28
|
-
*/
|
|
29
|
-
public static getInstance(
|
|
30
|
-
key: string = "runtime",
|
|
31
|
-
doc?: Document
|
|
32
|
-
): TabsController {
|
|
33
|
-
if (!TabsController.instances[key]) {
|
|
34
|
-
TabsController.instances[key] = new TabsController(doc);
|
|
35
|
-
} else if (doc) {
|
|
36
|
-
TabsController.instances[key].setDoc(doc);
|
|
37
|
-
}
|
|
38
|
-
return TabsController.instances[key];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 销毁指定 key 的实例
|
|
43
|
-
* @param key 实例的唯一标识
|
|
44
|
-
*/
|
|
45
|
-
public static destroyInstance(key: string = "runtime"): void {
|
|
46
|
-
if (TabsController.instances[key]) {
|
|
47
|
-
TabsController.instances[key].destroy();
|
|
48
|
-
delete TabsController.instances[key];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private setDoc(doc?: Document) {
|
|
53
|
-
this.doc = doc;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
mount() {
|
|
57
|
-
if (!this.doc) return () => {};
|
|
58
|
-
this.unmount();
|
|
59
|
-
// 实现标签页的挂载逻辑
|
|
60
|
-
const tabsList = this.doc.querySelectorAll(`[${DATA_TABS}]`);
|
|
61
|
-
tabsList.forEach((tabs) => {
|
|
62
|
-
const tabsId = tabs.getAttribute(DATA_TABS);
|
|
63
|
-
const tabsSelection = tabs.getAttribute(DATA_TABS_SELECTION);
|
|
64
|
-
const tabsTabs = tabs.querySelectorAll(`[${DATA_TABS_TAB}]`);
|
|
65
|
-
const tabsPanels = tabs.querySelectorAll(`[${DATA_TABS_PANEL}]`);
|
|
66
|
-
if (!tabsId) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
// 初始化选中标签
|
|
70
|
-
tabsTabs.forEach((tab, index) => {
|
|
71
|
-
if (tabsSelection && tabsSelection === (index + 1).toString()) {
|
|
72
|
-
tab.classList.add("selected");
|
|
73
|
-
} else {
|
|
74
|
-
tab.classList.remove("selected");
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// 给标签添加点击事件
|
|
78
|
-
const handleTabClick = () => {
|
|
79
|
-
const oldSeledction = tabs.getAttribute(DATA_TABS_SELECTION);
|
|
80
|
-
const newSelection = (index + 1).toString();
|
|
81
|
-
// 如果标签已经选中,则不进行操作
|
|
82
|
-
if (oldSeledction === newSelection) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
// 设置选中的标签
|
|
86
|
-
tabs.setAttribute(DATA_TABS_SELECTION, newSelection);
|
|
87
|
-
// 发出选中事件
|
|
88
|
-
this.select(tabsId, tab as HTMLElement, newSelection);
|
|
89
|
-
// 移除所有标签的选中状态
|
|
90
|
-
tabsTabs.forEach((tab, subIndex) => {
|
|
91
|
-
const tabKey = (subIndex + 1).toString();
|
|
92
|
-
if (oldSeledction === tabKey) {
|
|
93
|
-
tab.classList.remove("selected");
|
|
94
|
-
// 取消选中
|
|
95
|
-
this.unselect(tabsId, tab as HTMLElement, tabKey);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
tab.classList.add("selected");
|
|
99
|
-
|
|
100
|
-
// 设置选中的面板
|
|
101
|
-
tabsPanels.forEach((panel, subIndex) => {
|
|
102
|
-
panel.classList.remove("selected");
|
|
103
|
-
if (index === subIndex) {
|
|
104
|
-
panel.classList.add("selected");
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
// 添加新的事件监听器
|
|
110
|
-
tab.addEventListener("click", handleTabClick);
|
|
111
|
-
this.unmountHandlers.push(() => {
|
|
112
|
-
tab.removeEventListener("click", handleTabClick);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
// 初始化选中面板
|
|
117
|
-
tabsPanels.forEach((panel, index) => {
|
|
118
|
-
if (tabsSelection && tabsSelection === (index + 1).toString()) {
|
|
119
|
-
panel.classList.add("selected");
|
|
120
|
-
} else {
|
|
121
|
-
panel.classList.remove("selected");
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
const unsub2 = this.initTabsMotion();
|
|
126
|
-
this.unmountHandlers.push(unsub2);
|
|
127
|
-
return () => {
|
|
128
|
-
// 返回清理函数
|
|
129
|
-
this.unmountHandlers.forEach((unmountHandler) => {
|
|
130
|
-
unmountHandler();
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
//初始化选项卡Selection动画
|
|
136
|
-
initTabsMotion() {
|
|
137
|
-
const unsub = this.onSelected((event: SelectionEvent) => {
|
|
138
|
-
//查找对应的data-motion-selection元素
|
|
139
|
-
const tabsElement = this.doc?.querySelector(
|
|
140
|
-
`[${DATA_TABS}=${event.key}]`
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
if (
|
|
144
|
-
this.doc?.defaultView &&
|
|
145
|
-
tabsElement instanceof this.doc?.defaultView.HTMLElement
|
|
146
|
-
) {
|
|
147
|
-
//该容器下,所有带有选中动画的元素
|
|
148
|
-
tabsElement
|
|
149
|
-
.querySelectorAll(`[${DATA_MOTION_SELECTION}]`)
|
|
150
|
-
.forEach((element) => {
|
|
151
|
-
const motions = (element as HTMLElement).dataset.motionSelection;
|
|
152
|
-
if (motions) {
|
|
153
|
-
const animation = JSON.parse(motions) as
|
|
154
|
-
| AnimationConfig
|
|
155
|
-
| undefined;
|
|
156
|
-
if (animation) {
|
|
157
|
-
applyAnimation(element, animation);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
const unsub2 = this.onUnSelected((event: SelectionEvent) => {
|
|
165
|
-
//查找对应的data-motion-selection元素
|
|
166
|
-
const tabsElement = this.doc?.querySelector(
|
|
167
|
-
`[${DATA_TABS}=${event.key}]`
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
if (
|
|
171
|
-
this.doc?.defaultView &&
|
|
172
|
-
tabsElement instanceof this.doc?.defaultView.HTMLElement
|
|
173
|
-
) {
|
|
174
|
-
//该容器下,所有带有选中动画的元素
|
|
175
|
-
// tabsElement
|
|
176
|
-
// .querySelectorAll(`[${DATA_MOTION_SELECTION}]`)
|
|
177
|
-
// .forEach((element) => {
|
|
178
|
-
// const motions = (element as HTMLElement).dataset.motionSelection;
|
|
179
|
-
// if (motions) {
|
|
180
|
-
// const animation = JSON.parse(motions) as
|
|
181
|
-
// | AnimationConfig
|
|
182
|
-
// | undefined;
|
|
183
|
-
// if (animation) {
|
|
184
|
-
// applyAnimation(element, animation);
|
|
185
|
-
// }
|
|
186
|
-
// }
|
|
187
|
-
// });
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
return () => {
|
|
192
|
-
unsub();
|
|
193
|
-
unsub2();
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
unmount() {
|
|
198
|
-
this.unmountHandlers.forEach((handler) => handler());
|
|
199
|
-
this.unmountHandlers = [];
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* 监听选项被选中事件
|
|
203
|
-
*
|
|
204
|
-
* @param callback - 选项被选中时的回调函数
|
|
205
|
-
* @returns 取消监听的函数
|
|
206
|
-
*/
|
|
207
|
-
public onSelected = (
|
|
208
|
-
callback: (event: SelectionEvent) => VoidFunction | void
|
|
209
|
-
): (() => void) => {
|
|
210
|
-
if (!this.doc) return () => {};
|
|
211
|
-
|
|
212
|
-
return this.eventBus.on(EVENT_SELECT, callback);
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* 监听选项取消选中事件
|
|
217
|
-
*
|
|
218
|
-
* @param callback - 选项取消选中时的回调函数
|
|
219
|
-
* @returns 取消监听的函数
|
|
220
|
-
*/
|
|
221
|
-
public onUnSelected = (
|
|
222
|
-
callback: (event: SelectionEvent) => VoidFunction | void
|
|
223
|
-
): (() => void) => {
|
|
224
|
-
if (!this.doc) return () => {};
|
|
225
|
-
|
|
226
|
-
return this.eventBus.on(EVENT_UNSELECT, callback);
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* 选择
|
|
231
|
-
* @param key - 选项的唯一标识
|
|
232
|
-
* @param target - 触发选择的目标元素
|
|
233
|
-
* @param selection - 选择的值
|
|
234
|
-
*/
|
|
235
|
-
select = (key: string, target: HTMLElement, selection: string): void => {
|
|
236
|
-
if (this.doc) {
|
|
237
|
-
try {
|
|
238
|
-
this.eventBus.emit(EVENT_SELECT, { key, target, selection });
|
|
239
|
-
} catch (error) {
|
|
240
|
-
console.error(`触发选择事件失败: ${key}`, error);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* 取消选择
|
|
247
|
-
* @param key - 选项的唯一标识
|
|
248
|
-
* @param target - 触发取消选择的目标元素
|
|
249
|
-
* @param selection - 取消选择的值
|
|
250
|
-
*/
|
|
251
|
-
unselect = (key: string, target: HTMLElement, selection: string): void => {
|
|
252
|
-
if (this.doc) {
|
|
253
|
-
try {
|
|
254
|
-
this.eventBus.emit(EVENT_UNSELECT, { key, target, selection });
|
|
255
|
-
} catch (error) {
|
|
256
|
-
console.error(`触发取消选择事件失败: ${key}`, error);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
destroy() {
|
|
262
|
-
// 实现销毁逻辑
|
|
263
|
-
this.eventBus.destroy();
|
|
264
|
-
this.unmount();
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
export const tabs = TabsController.getInstance(
|
|
269
|
-
"runtime",
|
|
270
|
-
typeof document !== "undefined" ? document : undefined
|
|
271
|
-
);
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { AnimationConfig, convertToGsapVars } from "../motion";
|
|
2
|
-
import { gsap } from "gsap/dist/gsap";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 根据AnimationConfig选择并应用正确的GSAP动画方法
|
|
6
|
-
* @param element 目标元素
|
|
7
|
-
* @param config 动画配置
|
|
8
|
-
* @param options 额外选项
|
|
9
|
-
* @returns GSAP动画实例
|
|
10
|
-
*/
|
|
11
|
-
export function applyAnimation(
|
|
12
|
-
element: Element,
|
|
13
|
-
config: AnimationConfig,
|
|
14
|
-
options: {
|
|
15
|
-
onComplete?: () => void;
|
|
16
|
-
ensureVisibleOnComplete?: boolean;
|
|
17
|
-
} = {}
|
|
18
|
-
): gsap.core.Tween | null {
|
|
19
|
-
// 处理onComplete回调
|
|
20
|
-
const addOnComplete = (vars: gsap.TweenVars) => {
|
|
21
|
-
if (options.ensureVisibleOnComplete || options.onComplete) {
|
|
22
|
-
const originalOnComplete = vars.onComplete;
|
|
23
|
-
vars.onComplete = function () {
|
|
24
|
-
// 确保元素可见(如果需要)
|
|
25
|
-
if (options.ensureVisibleOnComplete && element instanceof HTMLElement) {
|
|
26
|
-
element.style.opacity = "1";
|
|
27
|
-
element.style.visibility = "visible";
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// 调用原始的onComplete回调(如果有)
|
|
31
|
-
if (originalOnComplete && typeof originalOnComplete === "function") {
|
|
32
|
-
originalOnComplete.call(this);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 调用额外的onComplete回调(如果有)
|
|
36
|
-
if (options.onComplete) {
|
|
37
|
-
options.onComplete();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
return vars;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// 处理from动画
|
|
45
|
-
if (config.from) {
|
|
46
|
-
const fromVars = { ...config.from } as gsap.TweenVars;
|
|
47
|
-
|
|
48
|
-
// 复制动画控制参数
|
|
49
|
-
if (config.duration) fromVars.duration = config.duration;
|
|
50
|
-
if (config.delay) fromVars.delay = config.delay;
|
|
51
|
-
if (config.ease) fromVars.ease = config.ease;
|
|
52
|
-
|
|
53
|
-
// 添加onComplete回调
|
|
54
|
-
addOnComplete(fromVars);
|
|
55
|
-
|
|
56
|
-
// 使用gsap.from
|
|
57
|
-
return gsap.from(element, fromVars);
|
|
58
|
-
}
|
|
59
|
-
// 处理fromTo动画
|
|
60
|
-
else if (config.fromTo) {
|
|
61
|
-
const fromVars = { ...config.fromTo.from };
|
|
62
|
-
const toVars = { ...config.fromTo.to } as gsap.TweenVars;
|
|
63
|
-
|
|
64
|
-
// 复制动画控制参数到toVars
|
|
65
|
-
if (config.duration) toVars.duration = config.duration;
|
|
66
|
-
if (config.delay) toVars.delay = config.delay;
|
|
67
|
-
if (config.ease) toVars.ease = config.ease;
|
|
68
|
-
|
|
69
|
-
// 添加onComplete回调
|
|
70
|
-
addOnComplete(toVars);
|
|
71
|
-
|
|
72
|
-
// 使用gsap.fromTo
|
|
73
|
-
return gsap.fromTo(element, fromVars, toVars);
|
|
74
|
-
}
|
|
75
|
-
// 处理to动画(默认)
|
|
76
|
-
else {
|
|
77
|
-
// 使用convertToGsapVars转换配置
|
|
78
|
-
const gsapVars = convertToGsapVars(config);
|
|
79
|
-
|
|
80
|
-
// 添加onComplete回调
|
|
81
|
-
addOnComplete(gsapVars);
|
|
82
|
-
|
|
83
|
-
// 使用gsap.to
|
|
84
|
-
return gsap.to(element, gsapVars);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { AnimationStyles } from "../motion";
|
|
2
|
-
import { gsap } from "gsap/dist/gsap";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 将动画配置应用到元素的初始状态
|
|
6
|
-
* @param element 目标元素
|
|
7
|
-
* @param initialConfig 初始配置
|
|
8
|
-
*/
|
|
9
|
-
export function applyInitialState(
|
|
10
|
-
element: HTMLElement,
|
|
11
|
-
initialConfig: AnimationStyles
|
|
12
|
-
): void {
|
|
13
|
-
if (!initialConfig) return;
|
|
14
|
-
|
|
15
|
-
// 创建GSAP变量对象
|
|
16
|
-
const initialVars = {} as gsap.TweenVars;
|
|
17
|
-
|
|
18
|
-
// 处理基本动画属性
|
|
19
|
-
if (initialConfig.opacity !== undefined)
|
|
20
|
-
initialVars.opacity = Number(initialConfig.opacity);
|
|
21
|
-
if (initialConfig.scale !== undefined)
|
|
22
|
-
initialVars.scale = Number(initialConfig.scale);
|
|
23
|
-
if (initialConfig.rotate !== undefined)
|
|
24
|
-
initialVars.rotation = Number(initialConfig.rotate);
|
|
25
|
-
|
|
26
|
-
// 处理位置相关属性
|
|
27
|
-
if (initialConfig.x !== undefined)
|
|
28
|
-
initialVars.x =
|
|
29
|
-
typeof initialConfig.x === "string"
|
|
30
|
-
? initialConfig.x
|
|
31
|
-
: Number(initialConfig.x);
|
|
32
|
-
if (initialConfig.y !== undefined)
|
|
33
|
-
initialVars.y =
|
|
34
|
-
typeof initialConfig.y === "string"
|
|
35
|
-
? initialConfig.y
|
|
36
|
-
: Number(initialConfig.y);
|
|
37
|
-
if (initialConfig.z !== undefined)
|
|
38
|
-
initialVars.z =
|
|
39
|
-
typeof initialConfig.z === "string"
|
|
40
|
-
? initialConfig.z
|
|
41
|
-
: Number(initialConfig.z);
|
|
42
|
-
|
|
43
|
-
// 处理尺寸属性
|
|
44
|
-
if (initialConfig.width !== undefined)
|
|
45
|
-
initialVars.width =
|
|
46
|
-
typeof initialConfig.width === "string"
|
|
47
|
-
? initialConfig.width
|
|
48
|
-
: Number(initialConfig.width);
|
|
49
|
-
if (initialConfig.height !== undefined)
|
|
50
|
-
initialVars.height =
|
|
51
|
-
typeof initialConfig.height === "string"
|
|
52
|
-
? initialConfig.height
|
|
53
|
-
: Number(initialConfig.height);
|
|
54
|
-
|
|
55
|
-
// 处理颜色和背景
|
|
56
|
-
if (initialConfig.color !== undefined)
|
|
57
|
-
initialVars.color = initialConfig.color;
|
|
58
|
-
if (initialConfig.backgroundColor !== undefined)
|
|
59
|
-
initialVars.backgroundColor = initialConfig.backgroundColor;
|
|
60
|
-
|
|
61
|
-
// 处理变换原点
|
|
62
|
-
if (initialConfig.transformOrigin !== undefined)
|
|
63
|
-
initialVars.transformOrigin = initialConfig.transformOrigin;
|
|
64
|
-
|
|
65
|
-
// 处理显示和可见性
|
|
66
|
-
if (initialConfig.display !== undefined)
|
|
67
|
-
initialVars.display = initialConfig.display as string;
|
|
68
|
-
if (initialConfig.visibility !== undefined)
|
|
69
|
-
initialVars.visibility = initialConfig.visibility as string;
|
|
70
|
-
|
|
71
|
-
// 处理自定义transform
|
|
72
|
-
if (initialConfig.transform !== undefined) {
|
|
73
|
-
// 直接设置style.transform,而不是通过GSAP
|
|
74
|
-
element.style.transform = initialConfig.transform;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// 设置初始状态
|
|
78
|
-
gsap.set(element, initialVars);
|
|
79
|
-
}
|
package/src/controller/consts.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
//弹层ID
|
|
2
|
-
export const DATA_OPENABLE = "data-openable";
|
|
3
|
-
|
|
4
|
-
//弹层角色,取值:Openable
|
|
5
|
-
export const DATA_OPENABLE_ROLE = "data-openable-role";
|
|
6
|
-
|
|
7
|
-
//弹层CTA,用于跟踪用户点击行为
|
|
8
|
-
export const DATA_POPUP_CTA = "data-popup-cta";
|
|
9
|
-
|
|
10
|
-
//已经进入过视窗
|
|
11
|
-
export const DATA_VIEWPORT_ENTERED = "data-viewport-entered";
|
|
12
|
-
|
|
13
|
-
export enum OpenAble {
|
|
14
|
-
PopoverContainer = "popover-container",
|
|
15
|
-
PopoverPanel = "popover-panel",
|
|
16
|
-
ModalContainer = "modal-container",
|
|
17
|
-
ModalTrigger = "modal-trigger",
|
|
18
|
-
ModalPanel = "modal-panel",
|
|
19
|
-
ModalCloser = "modal-closer",
|
|
20
|
-
CollapseContainer = "collapse-container",
|
|
21
|
-
CollapsePanel = "collapse-panel",
|
|
22
|
-
CollapseTrigger = "collapse-trigger",
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** 弹出层打开事件名称 */
|
|
26
|
-
export const EVENT_OPEN = "openable-open";
|
|
27
|
-
/** 弹出层关闭事件名称 */
|
|
28
|
-
export const EVENT_CLOSE = "openable-close";
|
|
29
|
-
|
|
30
|
-
/** 元素选中事件名称,比如tab切换 */
|
|
31
|
-
export const EVENT_SELECT = "element-select";
|
|
32
|
-
/** 元素取消选中事件名称 */
|
|
33
|
-
export const EVENT_UNSELECT = "element-unselect";
|
package/src/controller/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "./consts";
|
|
2
|
-
export * from "./utils";
|
|
3
|
-
export * from "./ModalController";
|
|
4
|
-
export * from "./AnimateController";
|
|
5
|
-
export * from "./AosController";
|
|
6
|
-
export * from "./CollapseController";
|
|
7
|
-
export * from "./PopoverController";
|
|
8
|
-
export * from "./PageLoader";
|
|
9
|
-
export * from "./TabsController";
|
|
10
|
-
export * from "./NumberController";
|
package/src/controller/utils.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SimpleAnimation,
|
|
3
|
-
ANIMATIONS,
|
|
4
|
-
DualAnimation,
|
|
5
|
-
AOS_ANIMATIONS,
|
|
6
|
-
} from "../motion";
|
|
7
|
-
|
|
8
|
-
export function normalizeSimpleAnimation(animation?: SimpleAnimation) {
|
|
9
|
-
if (animation?.preset) {
|
|
10
|
-
const preset = ANIMATIONS[animation?.preset];
|
|
11
|
-
return {
|
|
12
|
-
...preset,
|
|
13
|
-
keyframes: { ...preset.keyframes, ...animation.keyframes },
|
|
14
|
-
transition: { ...preset.transition, ...animation.transition },
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return animation;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//处理预置动画
|
|
22
|
-
export function normalizeDualAnimation(
|
|
23
|
-
animation?: DualAnimation
|
|
24
|
-
): DualAnimation | undefined {
|
|
25
|
-
if (!animation) {
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// 如果有预设,合并预设和自定义配置
|
|
30
|
-
if (animation.preset) {
|
|
31
|
-
const preset = AOS_ANIMATIONS[animation.preset];
|
|
32
|
-
return {
|
|
33
|
-
...animation,
|
|
34
|
-
in: animation.in
|
|
35
|
-
? normalizeSimpleAnimation({ ...preset.in, ...animation.in })
|
|
36
|
-
: preset.in,
|
|
37
|
-
out: animation.out
|
|
38
|
-
? normalizeSimpleAnimation({ ...preset.out, ...animation.out })
|
|
39
|
-
: preset.out,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// 如果没有预设,但有 in/out 配置
|
|
44
|
-
return {
|
|
45
|
-
in: animation.in ? normalizeSimpleAnimation(animation.in) : undefined,
|
|
46
|
-
out: animation.out ? normalizeSimpleAnimation(animation.out) : undefined,
|
|
47
|
-
};
|
|
48
|
-
}
|