@hua-labs/motion-core 2.4.0 → 2.4.1
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/LICENSE +21 -0
- package/dist/index.cjs +106 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +35 -14
- package/dist/index.d.ts +35 -14
- package/dist/index.mjs +106 -48
- package/dist/index.mjs.map +1 -1
- package/dist/native.d.mts +2 -2
- package/dist/native.d.ts +2 -2
- package/dist/{springPhysics-DLyZ4nbx.d.mts → springPhysics-BZVRi9PQ.d.mts} +71 -18
- package/dist/{springPhysics-DLyZ4nbx.d.ts → springPhysics-BZVRi9PQ.d.ts} +71 -18
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present HUA Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
CHANGED
|
@@ -942,6 +942,10 @@ function useFadeIn(options = {}) {
|
|
|
942
942
|
setProgress(0);
|
|
943
943
|
onReset?.();
|
|
944
944
|
}, [stop, onReset]);
|
|
945
|
+
const pause = react.useCallback(() => {
|
|
946
|
+
}, []);
|
|
947
|
+
const resume = react.useCallback(() => {
|
|
948
|
+
}, []);
|
|
945
949
|
react.useEffect(() => {
|
|
946
950
|
if (!ref.current || !autoStart) return;
|
|
947
951
|
return observeElement(
|
|
@@ -958,14 +962,25 @@ function useFadeIn(options = {}) {
|
|
|
958
962
|
stop();
|
|
959
963
|
};
|
|
960
964
|
}, [stop]);
|
|
961
|
-
const style = react.useMemo(
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
965
|
+
const style = react.useMemo(
|
|
966
|
+
() => ({
|
|
967
|
+
opacity: isVisible ? targetOpacity : initialOpacity,
|
|
968
|
+
transition: `opacity ${duration}ms ${easing}`,
|
|
969
|
+
"--motion-delay": `${delay}ms`,
|
|
970
|
+
"--motion-duration": `${duration}ms`,
|
|
971
|
+
"--motion-easing": easing,
|
|
972
|
+
"--motion-progress": `${progress}`
|
|
973
|
+
}),
|
|
974
|
+
[
|
|
975
|
+
isVisible,
|
|
976
|
+
targetOpacity,
|
|
977
|
+
initialOpacity,
|
|
978
|
+
duration,
|
|
979
|
+
easing,
|
|
980
|
+
delay,
|
|
981
|
+
progress
|
|
982
|
+
]
|
|
983
|
+
);
|
|
969
984
|
return {
|
|
970
985
|
ref,
|
|
971
986
|
isVisible,
|
|
@@ -974,7 +989,9 @@ function useFadeIn(options = {}) {
|
|
|
974
989
|
progress,
|
|
975
990
|
start,
|
|
976
991
|
stop,
|
|
977
|
-
reset
|
|
992
|
+
reset,
|
|
993
|
+
pause,
|
|
994
|
+
resume
|
|
978
995
|
};
|
|
979
996
|
}
|
|
980
997
|
function useSlideUp(options = {}) {
|
|
@@ -1063,6 +1080,10 @@ function useSlideUp(options = {}) {
|
|
|
1063
1080
|
setProgress(0);
|
|
1064
1081
|
onReset?.();
|
|
1065
1082
|
}, [stop, onReset]);
|
|
1083
|
+
const pause = react.useCallback(() => {
|
|
1084
|
+
}, []);
|
|
1085
|
+
const resume = react.useCallback(() => {
|
|
1086
|
+
}, []);
|
|
1066
1087
|
react.useEffect(() => {
|
|
1067
1088
|
if (!ref.current || !autoStart) return;
|
|
1068
1089
|
return observeElement(
|
|
@@ -1079,21 +1100,37 @@ function useSlideUp(options = {}) {
|
|
|
1079
1100
|
stop();
|
|
1080
1101
|
};
|
|
1081
1102
|
}, [stop]);
|
|
1082
|
-
const initialTransform = react.useMemo(
|
|
1103
|
+
const initialTransform = react.useMemo(
|
|
1104
|
+
() => getInitialTransform2(),
|
|
1105
|
+
[getInitialTransform2]
|
|
1106
|
+
);
|
|
1083
1107
|
const finalTransform = react.useMemo(() => {
|
|
1084
1108
|
return direction === "left" || direction === "right" ? "translateX(0)" : "translateY(0)";
|
|
1085
1109
|
}, [direction]);
|
|
1086
|
-
const style = react.useMemo(
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1110
|
+
const style = react.useMemo(
|
|
1111
|
+
() => ({
|
|
1112
|
+
opacity: isVisible ? 1 : 0,
|
|
1113
|
+
transform: isVisible ? finalTransform : initialTransform,
|
|
1114
|
+
transition: `opacity ${duration}ms ${easing}, transform ${duration}ms ${easing}`,
|
|
1115
|
+
"--motion-delay": `${delay}ms`,
|
|
1116
|
+
"--motion-duration": `${duration}ms`,
|
|
1117
|
+
"--motion-easing": easing,
|
|
1118
|
+
"--motion-progress": `${progress}`,
|
|
1119
|
+
"--motion-direction": direction,
|
|
1120
|
+
"--motion-distance": `${distance}px`
|
|
1121
|
+
}),
|
|
1122
|
+
[
|
|
1123
|
+
isVisible,
|
|
1124
|
+
initialTransform,
|
|
1125
|
+
finalTransform,
|
|
1126
|
+
duration,
|
|
1127
|
+
easing,
|
|
1128
|
+
delay,
|
|
1129
|
+
progress,
|
|
1130
|
+
direction,
|
|
1131
|
+
distance
|
|
1132
|
+
]
|
|
1133
|
+
);
|
|
1097
1134
|
return {
|
|
1098
1135
|
ref,
|
|
1099
1136
|
isVisible,
|
|
@@ -1102,7 +1139,9 @@ function useSlideUp(options = {}) {
|
|
|
1102
1139
|
progress,
|
|
1103
1140
|
start,
|
|
1104
1141
|
stop,
|
|
1105
|
-
reset
|
|
1142
|
+
reset,
|
|
1143
|
+
pause,
|
|
1144
|
+
resume
|
|
1106
1145
|
};
|
|
1107
1146
|
}
|
|
1108
1147
|
|
|
@@ -1182,6 +1221,10 @@ function useScaleIn(options = {}) {
|
|
|
1182
1221
|
}
|
|
1183
1222
|
onReset?.();
|
|
1184
1223
|
}, [stop, initialScale, onReset]);
|
|
1224
|
+
const pause = react.useCallback(() => {
|
|
1225
|
+
}, []);
|
|
1226
|
+
const resume = react.useCallback(() => {
|
|
1227
|
+
}, []);
|
|
1185
1228
|
react.useEffect(() => {
|
|
1186
1229
|
if (!ref.current || !autoStart) return;
|
|
1187
1230
|
return observeElement(
|
|
@@ -1198,15 +1241,18 @@ function useScaleIn(options = {}) {
|
|
|
1198
1241
|
stop();
|
|
1199
1242
|
};
|
|
1200
1243
|
}, [stop]);
|
|
1201
|
-
const style = react.useMemo(
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1244
|
+
const style = react.useMemo(
|
|
1245
|
+
() => ({
|
|
1246
|
+
transform: `scale(${scale})`,
|
|
1247
|
+
opacity,
|
|
1248
|
+
transition: `all ${duration}ms ${easing}`,
|
|
1249
|
+
"--motion-delay": `${delay}ms`,
|
|
1250
|
+
"--motion-duration": `${duration}ms`,
|
|
1251
|
+
"--motion-easing": easing,
|
|
1252
|
+
"--motion-progress": `${progress}`
|
|
1253
|
+
}),
|
|
1254
|
+
[scale, opacity, duration, easing, delay, progress]
|
|
1255
|
+
);
|
|
1210
1256
|
return {
|
|
1211
1257
|
ref,
|
|
1212
1258
|
isVisible,
|
|
@@ -1215,7 +1261,9 @@ function useScaleIn(options = {}) {
|
|
|
1215
1261
|
progress,
|
|
1216
1262
|
start,
|
|
1217
1263
|
reset,
|
|
1218
|
-
stop
|
|
1264
|
+
stop,
|
|
1265
|
+
pause,
|
|
1266
|
+
resume
|
|
1219
1267
|
};
|
|
1220
1268
|
}
|
|
1221
1269
|
function useBounceIn(options = {}) {
|
|
@@ -1293,6 +1341,10 @@ function useBounceIn(options = {}) {
|
|
|
1293
1341
|
}
|
|
1294
1342
|
onReset?.();
|
|
1295
1343
|
}, [stop, onReset]);
|
|
1344
|
+
const pause = react.useCallback(() => {
|
|
1345
|
+
}, []);
|
|
1346
|
+
const resume = react.useCallback(() => {
|
|
1347
|
+
}, []);
|
|
1296
1348
|
react.useEffect(() => {
|
|
1297
1349
|
if (!ref.current || !autoStart) return;
|
|
1298
1350
|
return observeElement(
|
|
@@ -1309,15 +1361,18 @@ function useBounceIn(options = {}) {
|
|
|
1309
1361
|
stop();
|
|
1310
1362
|
};
|
|
1311
1363
|
}, [stop]);
|
|
1312
|
-
const style = react.useMemo(
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1364
|
+
const style = react.useMemo(
|
|
1365
|
+
() => ({
|
|
1366
|
+
transform: `scale(${scale})`,
|
|
1367
|
+
opacity,
|
|
1368
|
+
transition: `all ${duration}ms ${easing}`,
|
|
1369
|
+
"--motion-delay": `${delay}ms`,
|
|
1370
|
+
"--motion-duration": `${duration}ms`,
|
|
1371
|
+
"--motion-easing": easing,
|
|
1372
|
+
"--motion-progress": `${progress}`
|
|
1373
|
+
}),
|
|
1374
|
+
[scale, opacity, duration, easing, delay, progress]
|
|
1375
|
+
);
|
|
1321
1376
|
return {
|
|
1322
1377
|
ref,
|
|
1323
1378
|
isVisible,
|
|
@@ -1326,7 +1381,9 @@ function useBounceIn(options = {}) {
|
|
|
1326
1381
|
progress,
|
|
1327
1382
|
start,
|
|
1328
1383
|
reset,
|
|
1329
|
-
stop
|
|
1384
|
+
stop,
|
|
1385
|
+
pause,
|
|
1386
|
+
resume
|
|
1330
1387
|
};
|
|
1331
1388
|
}
|
|
1332
1389
|
function usePulse(options = {}) {
|
|
@@ -2590,9 +2647,11 @@ function useReducedMotion() {
|
|
|
2590
2647
|
mediaQuery.removeEventListener("change", handleChange);
|
|
2591
2648
|
};
|
|
2592
2649
|
}, []);
|
|
2593
|
-
return
|
|
2594
|
-
|
|
2595
|
-
|
|
2650
|
+
return prefersReducedMotion;
|
|
2651
|
+
}
|
|
2652
|
+
function useReducedMotionObject() {
|
|
2653
|
+
const prefersReducedMotion = useReducedMotion();
|
|
2654
|
+
return { prefersReducedMotion };
|
|
2596
2655
|
}
|
|
2597
2656
|
function useWindowSize(options = {}) {
|
|
2598
2657
|
const {
|
|
@@ -6016,8 +6075,7 @@ function useSequence(sequence, options = {}) {
|
|
|
6016
6075
|
isPlaying,
|
|
6017
6076
|
currentIndex,
|
|
6018
6077
|
totalMotions: sequence.length,
|
|
6019
|
-
ref: motions[0]?.ref
|
|
6020
|
-
})
|
|
6078
|
+
ref: motions[0]?.ref ?? { current: null }
|
|
6021
6079
|
// 첫 번째 모션의 ref 반환
|
|
6022
6080
|
};
|
|
6023
6081
|
}
|
|
@@ -7503,6 +7561,7 @@ exports.usePageMotions = usePageMotions;
|
|
|
7503
7561
|
exports.usePerformanceMonitor = usePerformanceMonitor;
|
|
7504
7562
|
exports.usePulse = usePulse;
|
|
7505
7563
|
exports.useReducedMotion = useReducedMotion;
|
|
7564
|
+
exports.useReducedMotionObject = useReducedMotionObject;
|
|
7506
7565
|
exports.useRepeat = useRepeat;
|
|
7507
7566
|
exports.useScaleIn = useScaleIn;
|
|
7508
7567
|
exports.useScrollDirection = useScrollDirection;
|