File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed
Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff line change 11import * as React from 'react' ;
22import classNames from 'classnames' ;
33import ResizeObserver from 'rc-resize-observer' ;
4- import { getFullWidth } from './util' ;
54import Item from './Item' ;
65import { 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 }
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments