Skip to content

Commit 7958475

Browse files
committed
opacity when invisible
1 parent b5becb7 commit 7958475

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

assets/index.less

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
.@{overflow-prefix-cls} {
44
display: inline-flex;
55
flex-wrap: nowrap;
6+
max-width: 100%;
7+
// overflow: hidden;
68

79
&-item {
810
margin-left: 0.5em;

src/Overflow.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as React from 'react';
22
import classNames from 'classnames';
33
import ResizeObserver from 'rc-resize-observer';
4-
import { getFullWidth } from './util';
54
import Item from './Item';
65
import { useBatchState } from './hooks/useBatchState';
76

@@ -62,6 +61,7 @@ function Overflow<ItemType = any>(
6261
// ================================= Size =================================
6362
function onOverflowResize(_: object, element: HTMLElement) {
6463
setContainerWidth(element.clientWidth);
64+
console.log('~~~???>>>', element.clientWidth, element);
6565
}
6666

6767
function registerSize(key: React.Key, width: number) {
@@ -92,11 +92,23 @@ function Overflow<ItemType = any>(
9292
for (let i = 0; i < len; i += 1) {
9393
const itemWidth = itemWidths.get(getKey(data[i], i)) || 0;
9494
totalWidth += itemWidth;
95+
console.log(
96+
i,
97+
'>>>',
98+
totalWidth,
99+
itemWidth,
100+
overflowWidth,
101+
'|',
102+
totalWidth + overflowWidth,
103+
containerWidth,
104+
);
95105

96106
if (totalWidth + overflowWidth > containerWidth) {
97107
setDisplayCount(i - 1);
108+
break;
98109
} else if (i === len - 1) {
99110
setDisplayCount(len - 1);
111+
break;
100112
}
101113
}
102114
}

src/hooks/useBatchState.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export function useBatchState() {
2626
const value = statesRef.current[myIndex];
2727

2828
function setValue(val: any) {
29-
statesRef.current[myIndex] = typeof val === 'function' ? val(value) : val;
29+
statesRef.current[myIndex] =
30+
typeof val === 'function' ? val(statesRef.current[myIndex]) : val;
3031

3132
cancelBeforeFrame(beforeFrameId);
3233

0 commit comments

Comments
 (0)