@easyv/charts 1.3.5 → 1.3.7

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.
@@ -40,10 +40,14 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (props) {
40
40
 
41
41
  speed_.current = speed;
42
42
 
43
- var animation = function animation(timestamp) {
44
- var frame = Math.floor(timestamp * speed_.current) % 10000 / 100;
45
- target.current.style.transform = "translate(-".concat(frame, "%,0px)");
46
- target.current.nextSibling.style.transform = "translate(-".concat(frame, "%,0px)");
43
+ var startAnimation = function startAnimation(lineWidth) {
44
+ var animation = function animation(timestamp) {
45
+ var frame = Math.round(timestamp * speed_.current % (lineWidth * 100) / 100);
46
+ target.current.style.transform = "translate(-".concat(frame, "px,0px)");
47
+ target.current.nextSibling.style.transform = "translate(-".concat(frame, "px,0px)");
48
+ timer.current = requestAnimationFrame(animation);
49
+ };
50
+
47
51
  timer.current = requestAnimationFrame(animation);
48
52
  };
49
53
 
@@ -62,8 +66,9 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (props) {
62
66
  } else {
63
67
  //否则文本溢出
64
68
  if (!overflow) {
65
- cancelAnimationFrame(timer.current);
66
- timer.current = requestAnimationFrame(animation);
69
+ cancelAnimationFrame(timer.current); //startAnimation(entrie.target.offsetWidth);
70
+
71
+ startAnimation(entrie.boundingClientRect.width);
67
72
  setOverflow(true);
68
73
  }
69
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -20,12 +20,16 @@ export default memo((props) => {
20
20
  const [overflow, setOverflow] = useState(false);
21
21
  speed_.current = speed;
22
22
 
23
- const animation = (timestamp) => {
24
- let frame = (Math.floor(timestamp * speed_.current) % 10000) / 100;
25
- target.current.style.transform = `translate(-${frame}%,0px)`;
26
- target.current.nextSibling.style.transform = `translate(-${frame}%,0px)`;
23
+ const startAnimation = (lineWidth)=>{
24
+ const animation = (timestamp) => {
25
+ let frame = Math.round(((timestamp*speed_.current)%(lineWidth*100))/100);
26
+ target.current.style.transform = `translate(-${frame}px,0px)`;
27
+ target.current.nextSibling.style.transform = `translate(-${frame}px,0px)`;
28
+ timer.current = requestAnimationFrame(animation);
29
+ };
27
30
  timer.current = requestAnimationFrame(animation);
28
- };
31
+ }
32
+
29
33
 
30
34
  useEffect(() => {
31
35
  //初始化观察器,利用观察器来监视组件可视区域变化
@@ -43,7 +47,8 @@ export default memo((props) => {
43
47
  //否则文本溢出
44
48
  if (!overflow) {
45
49
  cancelAnimationFrame(timer.current);
46
- timer.current = requestAnimationFrame(animation);
50
+ startAnimation(entrie.target.offsetWidth);
51
+ //startAnimation(entrie.boundingClientRect.width);
47
52
  setOverflow(true);
48
53
  }
49
54
  }