@easyv/charts 1.4.22 → 1.4.25

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.
@@ -8,10 +8,11 @@ import React, {
8
8
  useRef,
9
9
  useContext,
10
10
  useCallback,
11
- useEffect
12
- } from 'react';
13
- import { useAxes, useTooltip, useCarouselAxisX, useAiData } from '../hooks';
14
- import { chartContext } from '../context';
11
+ useEffect,
12
+ forwardRef,
13
+ } from "react";
14
+ import { useAxes, useTooltip, useCarouselAxisX } from "../hooks";
15
+ import { chartContext } from "../context";
15
16
  import {
16
17
  ChartContainer,
17
18
  Legend,
@@ -27,7 +28,9 @@ import {
27
28
  Label,
28
29
  Mapping,
29
30
  BaseLine,
30
- } from '.';
31
+ Control,
32
+ } from ".";
33
+ import { getMousePos } from "../utils";
31
34
 
32
35
  const Chart = memo(
33
36
  ({
@@ -46,7 +49,7 @@ const Chart = memo(
46
49
  bandLength,
47
50
  tooltip,
48
51
  baseLine: {
49
- orientation: baseLineOri = '',
52
+ orientation: baseLineOri = "",
50
53
  config: baseLineConfig = {},
51
54
  data: baseLineData = [],
52
55
  },
@@ -54,7 +57,9 @@ const Chart = memo(
54
57
  config: tooltipConfig = {},
55
58
  config: { auto, manual, indicator = {} } = {},
56
59
  } = {},
57
- brush
60
+ brush,
61
+ isControlChart = false,
62
+ control = null,
58
63
  },
59
64
  style,
60
65
  originData,
@@ -71,11 +76,22 @@ const Chart = memo(
71
76
  onEmit,
72
77
  } = useContext(chartContext);
73
78
  const svg = useRef();
74
- const axes = useAxes({ axes: axesConfig, context });
79
+ const axes = useAxes({
80
+ axes: axesConfig,
81
+ context,
82
+ isControlChart,
83
+ control,
84
+ });
75
85
  const aiData = aiFormatter?aiFormatter(originData, axes, series):useAiData(originData, axes, series);
76
- const axisX = useCarouselAxisX(axes.get('x'), animation, isHover);
77
- const xLineRange = width-marginLeft-marginRight;
78
- const yLineRange = height-marginTop-marginBottom;
86
+ const axisX = useCarouselAxisX(
87
+ axes.get("x"),
88
+ animation,
89
+ isHover,
90
+ isControlChart,
91
+ control
92
+ );
93
+ const xLineRange = width - marginLeft - marginRight;
94
+ const yLineRange = height - marginTop - marginBottom;
79
95
 
80
96
  useEffect(()=>{
81
97
  if(aiData.length){
@@ -108,7 +124,8 @@ const Chart = memo(
108
124
  config: tooltipConfig,
109
125
  });
110
126
  const tooltipData = useMemo(
111
- () => tickName !== undefined && originData.filter((d) => d.x === tickName),
127
+ () =>
128
+ tickName !== undefined && originData.filter((d) => d.x === tickName),
112
129
  [tickName, originData]
113
130
  );
114
131
 
@@ -118,7 +135,7 @@ const Chart = memo(
118
135
  (auto || manual)
119
136
  );
120
137
 
121
- const isVertical = axisX.direction === 'vertical';
138
+ const isVertical = axisX.direction === "vertical";
122
139
 
123
140
  const indicatorWidth = (indicator.width * axisX.step) / 100;
124
141
  const position = axisX.scaler(tickName) - indicatorWidth / 2;
@@ -136,11 +153,160 @@ const Chart = memo(
136
153
  const { data } = e.currentTarget.dataset;
137
154
  const _data = JSON.parse(data);
138
155
  triggerOnRelative(_data);
139
- onEmit('click', _data);
156
+ onEmit("click", _data);
140
157
  },
141
158
  [triggerOnRelative, onEmit]
142
159
  );
143
-
160
+
161
+ /**
162
+ * 控制图相关
163
+ */
164
+ const controlEl = useRef();
165
+ const seriesEl = useRef(null);
166
+ const axisElList = useRef([]);
167
+ const curControlPercent = useRef(0);
168
+ useEffect(() => {
169
+ if (controlEl.current && isControlChart) {
170
+ let isDragging = false;
171
+ let movementX = 0;
172
+ let rawTranslateX = 0;
173
+ let percent = 0;
174
+ const controlWidth = (xLineRange * control.drag.width) / 100;
175
+ const range = (num) => {
176
+ let _num = num;
177
+ const min = 0;
178
+ const max = xLineRange - controlWidth;
179
+ _num = Math.max(_num, min);
180
+ _num = Math.min(_num, max);
181
+ return _num;
182
+ };
183
+ const setControlTranslate = (x) => {
184
+ const moveLen = range(x);
185
+ controlEl.current.style.transform = `translateX(${moveLen}px)`;
186
+ //计算出当前位移的百分比
187
+ percent = moveLen / (xLineRange - controlWidth);
188
+ curControlPercent.current = percent;
189
+ seriesEl.current.style.transform = `translate(${
190
+ -(axisX.controlEnd - axisX.end) * percent
191
+ }px,${marginTop}px)`;
192
+ axisElList.current[2].style.transform = `translate(${
193
+ -(axisX.controlEnd - axisX.end) * percent
194
+ }px,${0}px)`;
195
+ };
196
+ const mouseDownHandle = (e) => {
197
+ const mouseMoveHandle = (e) => {
198
+ //当前位移的距离
199
+ if (isDragging) {
200
+ movementX += e.movementX;
201
+ setControlTranslate(movementX + rawTranslateX);
202
+ }
203
+ };
204
+ const mouseUpHandle = (e) => {
205
+ rawTranslateX = range(movementX + rawTranslateX);
206
+ movementX = 0;
207
+ isDragging = false;
208
+ document.removeEventListener("mousemove", mouseMoveHandle);
209
+ document.removeEventListener("mouseup", mouseUpHandle);
210
+ };
211
+ document.addEventListener("mousemove", mouseMoveHandle);
212
+ document.addEventListener("mouseup", mouseUpHandle);
213
+ isDragging = true;
214
+ };
215
+
216
+ let animationHoverStop;
217
+ const setAnimationHoverStopTrue = () => {
218
+ animationHoverStop = true;
219
+ };
220
+ const setAnimationHoverStopFalse = () => {
221
+ animationHoverStop = false;
222
+ };
223
+ svg.current.addEventListener("mouseenter", setAnimationHoverStopTrue);
224
+ svg.current.addEventListener("mouseleave", setAnimationHoverStopFalse);
225
+
226
+ //控制图轮播动画逻辑
227
+ const { show, duration, interval, hover } = animation;
228
+ const times = Math.floor(xLineRange / controlWidth);
229
+ let animatePos = [];
230
+ for (let i = 0; i <= times; i++) {
231
+ if (i * controlWidth <= xLineRange) {
232
+ animatePos.push(i * controlWidth);
233
+ } else {
234
+ animatePos.push(xLineRange - controlWidth);
235
+ }
236
+ }
237
+ let index = 0;
238
+ let animationId;
239
+ if (animation.show) {
240
+ let initTime, timeGap;
241
+ const animation = (timestamp) => {
242
+ if (!initTime) {
243
+ initTime = timestamp;
244
+ }
245
+ if (animationHoverStop && hover) {
246
+ initTime = timestamp - timeGap;
247
+ }
248
+ timeGap = timestamp - initTime;
249
+ if (timeGap < (interval + duration) * 1000) {
250
+ if (timeGap < duration * 1000) {
251
+ const p = timeGap / (duration * 1000);
252
+ let nextIndex = index + 1;
253
+ let v;
254
+ if (nextIndex < animatePos.length) {
255
+ v =
256
+ p * (animatePos[nextIndex] - animatePos[index]) +
257
+ animatePos[index];
258
+ } else {
259
+ nextIndex = 0;
260
+ v = (1 - p) * animatePos[index];
261
+ }
262
+ setControlTranslate(v);
263
+ }
264
+ animationId = window.requestAnimationFrame(animation);
265
+ } else {
266
+ index = index < times ? index + 1 : 0;
267
+ initTime = 0;
268
+ animationId = window.requestAnimationFrame(animation);
269
+ }
270
+ };
271
+ animationId = window.requestAnimationFrame(animation);
272
+ }
273
+ controlEl.current.addEventListener("mousedown", mouseDownHandle);
274
+
275
+ return () => {
276
+ controlEl.current.removeEventListener("mousedown", mouseDownHandle);
277
+ svg.current.removeEventListener(
278
+ "mouseenter",
279
+ setAnimationHoverStopTrue
280
+ );
281
+ svg.current.removeEventListener(
282
+ "mouseleave",
283
+ setAnimationHoverStopFalse
284
+ );
285
+
286
+ window.cancelAnimationFrame(animationId);
287
+ };
288
+ }
289
+ }, [JSON.stringify(animation), control]);
290
+
291
+ const [controlChartTooltipShow, setControlChartTooltipShow] =
292
+ useState(false);
293
+ const [controlChartTooltipXName, setControlChartTooltipXName] =
294
+ useState(undefined);
295
+ const [controlChartTooltipX, setControlChartTooltipX] = useState(undefined);
296
+ const controlChartTooltipData = useMemo(
297
+ () =>
298
+ controlChartTooltipXName !== undefined &&
299
+ originData.filter((d) => d.x === controlChartTooltipXName),
300
+ [controlChartTooltipXName, originData]
301
+ );
302
+ const [controlChartIndicatorList, setControlChartIndicatorList] = useState(
303
+ axisX.ticks.map((tick) => {
304
+ return {
305
+ tick: tick,
306
+ isShow: false,
307
+ };
308
+ })
309
+ );
144
310
  return (
145
311
  <>
146
312
  <ChartContainer
@@ -149,16 +315,22 @@ const Chart = memo(
149
315
  height={height}
150
316
  marginLeft={marginLeft}
151
317
  marginTop={marginTop}
152
- onMouseEnter={()=>{setIsHover(true)}}
153
- onMouseMove={setIndex}
154
- onMouseLeave={(e)=>{setIsHover(false);setIndex(e)}}
318
+ onMouseEnter={() => {
319
+ setIsHover(true);
320
+ }}
321
+ onMouseLeave={(e) => {
322
+ setIsHover(false);
323
+ setIndex(e);
324
+ }}
155
325
  ref={svg}
156
326
  >
157
327
  {background && (
158
- <foreignObject style={{
159
- width:xLineRange,
160
- height:yLineRange
161
- }}>
328
+ <foreignObject
329
+ style={{
330
+ width: xLineRange,
331
+ height: yLineRange,
332
+ }}
333
+ >
162
334
  <svg width="100%" height="100%">
163
335
  <Background
164
336
  length={isVertical ? chartWidth : chartHeight}
@@ -169,19 +341,100 @@ const Chart = memo(
169
341
  </svg>
170
342
  </foreignObject>
171
343
  )}
172
- {showTooltip && <Indicator {...indicator} {...indicatorAttr} />}
173
- <foreignObject style={isVertical?{
174
- width:xLineRange+marginRight+marginLeft,
175
- height:yLineRange,
176
- transform:`translateX(${-marginRight}px)`,
177
- }:{
178
- width:xLineRange,
179
- height:yLineRange+marginTop+marginBottom,
180
- transform:`translateY(${-marginTop}px)`,
181
- // overflow:'visible'
182
- // paddingTop:marginTop
183
- }}>
184
- <svg width="100%" height="100%" style={{overflow:"visible",transform:isVertical?`translateX(${marginRight}px)`:`translateY(${marginTop}px)`}}>
344
+ {[...axes.values()].reverse().map((item, index) => {
345
+ const config = item.axisType == "x" ? axisX : item;
346
+
347
+ return (
348
+ <Axis
349
+ ref={(d) => {
350
+ axisElList.current[index] = d;
351
+ }}
352
+ triggerClick={onInteraction}
353
+ xLineRange={xLineRange}
354
+ yLineRange={yLineRange}
355
+ isControlChart={isControlChart}
356
+ controlConfig={control}
357
+ {...config}
358
+ key={index}
359
+ />
360
+ );
361
+ })}
362
+ {/* 控制条逻辑 */}
363
+ {isControlChart && control && (
364
+ <Control
365
+ ref={controlEl}
366
+ props={{
367
+ control,
368
+ axes,
369
+ series,
370
+ xLineRange,
371
+ yLineRange,
372
+ marginTop,
373
+ axisX,
374
+ bandLength,
375
+ }}
376
+ ></Control>
377
+ )}
378
+ {showTooltip && !isControlChart && (
379
+ <Indicator {...indicator} {...indicatorAttr} />
380
+ )}
381
+
382
+ <foreignObject
383
+ style={
384
+ isVertical
385
+ ? {
386
+ width: xLineRange + marginRight + marginLeft,
387
+ height: yLineRange,
388
+ transform: `translateX(${-marginRight}px)`,
389
+ }
390
+ : {
391
+ width: xLineRange,
392
+ height: yLineRange + marginTop + marginBottom,
393
+ transform: `translateY(${-marginTop}px)`,
394
+ }
395
+ }
396
+ >
397
+ <svg
398
+ width="100%"
399
+ height="100%"
400
+ ref={seriesEl}
401
+ style={{
402
+ overflow: "visible",
403
+ transform: isVertical
404
+ ? `translateX(${marginRight}px)`
405
+ : `translateY(${marginTop}px)`,
406
+ }}
407
+ >
408
+ {/* 控制图指示器部分 */}
409
+ <g>
410
+ {isControlChart &&
411
+ controlChartIndicatorList.map((item, index) => {
412
+ const x = axisX.scaler(item.tick);
413
+ return (
414
+ <Indicator
415
+ key={index}
416
+ {...indicator}
417
+ {...{
418
+ height: chartHeight,
419
+ width: indicatorWidth,
420
+ x: x - indicatorWidth / 2,
421
+ }}
422
+ isControlChart={isControlChart}
423
+ xName={item.tick}
424
+ setControlChartTooltipXName={
425
+ setControlChartTooltipXName
426
+ }
427
+ setControlChartTooltipX={setControlChartTooltipX}
428
+ setControlChartTooltipShow={setControlChartTooltipShow}
429
+ controlChartIndicatorList={controlChartIndicatorList}
430
+ setControlChartIndicatorList={
431
+ setControlChartIndicatorList
432
+ }
433
+ />
434
+ );
435
+ })}
436
+ </g>
437
+
185
438
  {series.map(({ Component, yOrZ, ...config }, index) => {
186
439
  const yAxis = axes.get(yOrZ);
187
440
  return (
@@ -193,11 +446,21 @@ const Chart = memo(
193
446
  bandLength={bandLength}
194
447
  xAxis={axisX}
195
448
  yAxis={yAxis}
449
+ // 控制图部分,主要是为了,当鼠标悬浮在指示器上时,显示对应的tooltip
450
+ isControlChart={isControlChart}
451
+ setControlChartTooltipXName={setControlChartTooltipXName}
452
+ setControlChartTooltipX={setControlChartTooltipX}
453
+ setControlChartTooltipShow={setControlChartTooltipShow}
454
+ indicatorWidth={indicatorWidth}
196
455
  triggerClick={onInteraction}
456
+ setControlChartIndicatorList={
457
+ setControlChartIndicatorList
458
+ }
197
459
  />
198
460
  )
199
461
  );
200
- })}
462
+ })}
463
+
201
464
  {series.map(({ Component, yOrZ, ...config }, index) => {
202
465
  const yAxis = axes.get(yOrZ);
203
466
  return (
@@ -215,12 +478,7 @@ const Chart = memo(
215
478
  })}
216
479
  </svg>
217
480
  </foreignObject>
218
- {[...axes.values()].reverse().map((item, index) => {
219
- const config = item.axisType == 'x' ? axisX : item;
220
- return (
221
- <Axis triggerClick={onInteraction} xLineRange={xLineRange} yLineRange={yLineRange} {...config} key={index} />
222
- );
223
- })}
481
+
224
482
  {baseLineData &&
225
483
  baseLineData.length > 0 &&
226
484
  baseLineData.map((item, index) => {
@@ -246,7 +504,7 @@ const Chart = memo(
246
504
  })}
247
505
  </ChartContainer>
248
506
  <Legend {...legend} filterData={filterData} series={series} />
249
- {showTooltip && (
507
+ {showTooltip && !isControlChart && (
250
508
  <Tooltip
251
509
  isVertical={isVertical}
252
510
  {...tooltip}
@@ -260,6 +518,24 @@ const Chart = memo(
260
518
  height={height}
261
519
  />
262
520
  )}
521
+
522
+ {controlChartTooltipShow && isControlChart && (
523
+ <Tooltip
524
+ isVertical={isVertical}
525
+ {...tooltip}
526
+ data={controlChartTooltipData}
527
+ x={
528
+ controlChartTooltipX -
529
+ (axisX.controlEnd - axisX.end) * curControlPercent.current
530
+ }
531
+ marginLeft={marginLeft}
532
+ marginTop={marginTop}
533
+ tickName={controlChartTooltipXName}
534
+ series={series}
535
+ width={width}
536
+ height={height}
537
+ />
538
+ )}
263
539
  {brush && <Brush config={brush} width={width} />}
264
540
  </>
265
541
  );
@@ -7,7 +7,7 @@ import React, {
7
7
  ReactChild,
8
8
  ReactEventHandler,
9
9
  LegacyRef,
10
- } from 'react';
10
+ } from "react";
11
11
  const event = () => {};
12
12
 
13
13
  type Props = {
@@ -41,10 +41,10 @@ export default memo(
41
41
  onMouseOut = event,
42
42
  }: Props,
43
43
  ref: LegacyRef<SVGSVGElement>
44
- ) =>
45
- {
46
- return <svg
47
- className='__easyv-svg'
44
+ ) => {
45
+ return (
46
+ <svg
47
+ className="__easyv-svg"
48
48
  width={width}
49
49
  height={height}
50
50
  onMouseEnter={onMouseEnter}
@@ -53,12 +53,19 @@ export default memo(
53
53
  onClick={onClick}
54
54
  onMouseMove={onMouseMove}
55
55
  ref={ref}
56
- style={{ position: 'absolute', width, height, ...style }}
56
+ style={{
57
+ overflow: "visible",
58
+ position: "absolute",
59
+ width,
60
+ height,
61
+ ...style,
62
+ }}
57
63
  >
58
- <g transform={'translate(' + marginLeft + ', ' + marginTop + ')'}>
64
+ <g transform={"translate(" + marginLeft + ", " + marginTop + ")"}>
59
65
  {children}
60
66
  </g>
61
67
  </svg>
62
- }
68
+ );
69
+ }
63
70
  )
64
71
  );
@@ -0,0 +1,51 @@
1
+ import React, { forwardRef, memo, useRef } from "react";
2
+ import { scaleLinear } from "d3-scale";
3
+
4
+ export default memo(forwardRef((props, ref) => {
5
+ const { props: { control, axes, series, xLineRange, yLineRange, marginTop, axisX, bandLength } } = props;
6
+ const _axisX = { ...axisX, scaler: axisX.controlDragScaler }
7
+ return (
8
+ <>
9
+ <foreignObject
10
+ style={{
11
+ width: xLineRange,
12
+ height: control.height,
13
+ backgroundColor: control.color,
14
+ // padding: ` 0 ${control.margin.left}px 0 ${control.margin.right}px`,
15
+ transform: `translateY(${yLineRange + marginTop}px)`,
16
+ }}
17
+ >
18
+ <svg width="100%" height="100%">
19
+ {series.map(({ Component, yOrZ, ...config }, index) => {
20
+ const yAxis = axes.get(yOrZ);
21
+ const cloneYAxis = JSON.parse(JSON.stringify(yAxis));
22
+ //todo range
23
+ cloneYAxis.scaler = scaleLinear()
24
+ .domain(yAxis.domain)
25
+ .range([control.height, 0]);
26
+ return (
27
+ yAxis &&
28
+ Component && (
29
+ <Component
30
+ key={index}
31
+ {...config}
32
+ bandLength={bandLength}
33
+ xAxis={_axisX}
34
+ yAxis={cloneYAxis}
35
+ />
36
+ )
37
+ );
38
+ })}
39
+ {/* 控制条 */}
40
+ <rect
41
+ ref={ref}
42
+ height={control.height}
43
+ width={(xLineRange * control.drag.width) / 100}
44
+ fill={control.drag.color}
45
+ ></rect>
46
+ </svg>
47
+ </foreignObject>
48
+ </>
49
+ );
50
+ }))
51
+
@@ -1,13 +1,61 @@
1
1
  /**
2
2
  * 轴类图表移上去的指示框背景
3
3
  */
4
- export default ({ color, height, width, x = 0, y = 0 }) => (
5
- <rect
6
- width={width}
7
- height={height}
8
- x={x}
9
- y={y}
10
- fill={color}
11
- stroke='none'
12
- />
13
- );
4
+ import { useState } from "react";
5
+ export default ({
6
+ color,
7
+ height,
8
+ width,
9
+ x = 0,
10
+ y = 0,
11
+ isControlChart = false,
12
+ xName = null,
13
+ setControlChartTooltipShow = null,
14
+ setControlChartTooltipXName = null,
15
+ setControlChartTooltipX = null,
16
+ setControlChartIndicatorList = null,
17
+ controlChartIndicatorList = null,
18
+ }) => {
19
+ let isShow = true;
20
+ if (isControlChart && controlChartIndicatorList) {
21
+ isShow = controlChartIndicatorList.find(
22
+ (item) => item.tick === xName
23
+ ).isShow;
24
+ }
25
+ return (
26
+ <rect
27
+ width={width}
28
+ height={height}
29
+ x={x}
30
+ onMouseEnter={() => {
31
+ if (isControlChart) {
32
+ setControlChartIndicatorList((v) => {
33
+ return v.map((item) => {
34
+ if (item.tick === xName) {
35
+ return { ...item, isShow: true };
36
+ } else {
37
+ return item;
38
+ }
39
+ });
40
+ });
41
+ setControlChartTooltipShow(true);
42
+ setControlChartTooltipXName(xName);
43
+ setControlChartTooltipX(x);
44
+ }
45
+ }}
46
+ onMouseLeave={() => {
47
+ if (isControlChart) {
48
+ setControlChartIndicatorList((v) =>
49
+ v.map((item) => ({ ...item, isShow: false }))
50
+ );
51
+ setControlChartTooltipShow(false);
52
+ setControlChartTooltipXName(undefined);
53
+ setControlChartTooltipX(undefined);
54
+ }
55
+ }}
56
+ fill={isShow ? color : "transparent"}
57
+ y={y}
58
+ stroke="none"
59
+ />
60
+ );
61
+ };
@@ -19,6 +19,13 @@ export default memo(
19
19
  xAxis: { scaler: xScaler, step, direction },
20
20
  yAxis: { scaler: yScaler, isClipAxis, clipValue },
21
21
  triggerClick,
22
+ //控制图相关
23
+ indicatorWidth,
24
+ setControlChartTooltipShow,
25
+ setControlChartTooltipX,
26
+ setControlChartTooltipXName,
27
+ isControlChart = false,
28
+ setControlChartIndicatorList = null,
22
29
  }) => {
23
30
  const lineType = config.hasOwnProperty("line"); // 堆叠处理
24
31
  const showIcon = icon && icon.show;
@@ -97,6 +104,32 @@ export default memo(
97
104
  <g
98
105
  key={i}
99
106
  onClick={triggerClick}
107
+ onMouseEnter={() => {
108
+ if (isControlChart) {
109
+ setControlChartIndicatorList((v) => {
110
+ return v.map((item) => {
111
+ if (item.tick === data.x) {
112
+ return { ...item, isShow: true };
113
+ } else {
114
+ return item;
115
+ }
116
+ });
117
+ });
118
+ setControlChartTooltipShow(true);
119
+ setControlChartTooltipX(xScaler(x) - indicatorWidth / 2);
120
+ setControlChartTooltipXName(data.x);
121
+ }
122
+ }}
123
+ onMouseLeave={() => {
124
+ if (isControlChart) {
125
+ setControlChartIndicatorList((v) =>
126
+ v.map((item) => ({ ...item, isShow: false }))
127
+ );
128
+ setControlChartTooltipShow(false);
129
+ setControlChartTooltipXName(undefined);
130
+ setControlChartTooltipX(undefined);
131
+ }
132
+ }}
100
133
  style={{ cursor: "pointer" }}
101
134
  data-data={JSON.stringify(data)}
102
135
  >
@@ -40,7 +40,7 @@ export default memo(forwardRef((props:marquee, ref:any) => {
40
40
  observe.current = new IntersectionObserver(
41
41
  function (entries:any) {
42
42
  let entrie = entries[0];
43
- if (entrie.boundingClientRect.width < entrie.rootBounds.width) {
43
+ if (entrie.boundingClientRect.width <= entrie.rootBounds.width) {
44
44
  //表示文字全部可视
45
45
  cancelAnimationFrame(timer.current||0);
46
46
  target.current!.style.transform = "translate(0px,0px)"; //重置偏移