@aura-react-comp/motion 0.2.5 → 0.2.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marquee.d.ts","sourceRoot":"","sources":["marquee.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"marquee.d.ts","sourceRoot":"","sources":["marquee.tsx"],"names":[],"mappings":";AAiBA,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW;IACX,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,oBAAoB;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,wBAAgB,OAAO,CAAC,EACtB,QAAQ,EACR,QAAa,EACb,SAAkB,EAClB,GAAQ,EACR,SAAS,EACT,KAAK,GACN,EAAE,YAAY,+BA0Cd"}
|
package/esm/primitive/marquee.js
CHANGED
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
* - 只动画 transform(合成器友好);
|
|
7
7
|
* - 单份内容宽度需 ≥ 容器宽度,否则回绕处会露出空隙;
|
|
8
8
|
* - reduced-motion 下静态展示(不滚动)。
|
|
9
|
+
*
|
|
10
|
+
* 回绕对齐的关键:间距必须放在**每份内容的尾部**(paddingRight),而不是用
|
|
11
|
+
* 外层 flex 的 gap。若用外层 gap,总宽为 2c + g,-50% 位移是 c + g/2,
|
|
12
|
+
* 与一个完整周期(c + g)差 g/2,每次回绕都会「往回跳」一下(闪回)。
|
|
13
|
+
* 改为尾部 padding 后总宽为 2(c + g),-50% 正好等于一个周期。
|
|
9
14
|
*/
|
|
10
15
|
import { motion, useReducedMotion } from 'motion/react';
|
|
11
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -31,15 +36,16 @@ export function Marquee({
|
|
|
31
36
|
children: children
|
|
32
37
|
});
|
|
33
38
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
|
|
40
|
+
// 尾部 padding 保证「两份之间」与「份内元素之间」的间隔一致,
|
|
41
|
+
// 从而 -50% 位移正好落在一个周期上。
|
|
42
|
+
const trackStyle = {
|
|
43
|
+
display: 'flex',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
gap,
|
|
46
|
+
flexShrink: 0,
|
|
47
|
+
paddingRight: gap
|
|
48
|
+
};
|
|
43
49
|
return /*#__PURE__*/_jsx("div", {
|
|
44
50
|
className: className,
|
|
45
51
|
style: {
|
|
@@ -47,11 +53,9 @@ export function Marquee({
|
|
|
47
53
|
position: 'relative',
|
|
48
54
|
...style
|
|
49
55
|
},
|
|
50
|
-
"aria-hidden": false,
|
|
51
56
|
children: /*#__PURE__*/_jsxs(motion.div, {
|
|
52
57
|
style: {
|
|
53
58
|
display: 'flex',
|
|
54
|
-
gap,
|
|
55
59
|
width: 'max-content'
|
|
56
60
|
},
|
|
57
61
|
animate: {
|
|
@@ -62,7 +66,14 @@ export function Marquee({
|
|
|
62
66
|
repeat: Infinity,
|
|
63
67
|
ease: 'linear'
|
|
64
68
|
},
|
|
65
|
-
children: [
|
|
69
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
70
|
+
style: trackStyle,
|
|
71
|
+
children: children
|
|
72
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
73
|
+
style: trackStyle,
|
|
74
|
+
"aria-hidden": "true",
|
|
75
|
+
children: children
|
|
76
|
+
})]
|
|
66
77
|
})
|
|
67
78
|
});
|
|
68
79
|
}
|