File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
src/packages/infiniteloading Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export interface InfiniteLoadingProps extends BasicComponent {
2323 onRefresh : ( ) => Promise < void >
2424 onLoadMore : ( ) => Promise < void >
2525 onScroll : ( param : number ) => void
26+ defaultScrollTop ?: number
2627}
2728
2829declare let window : Window & { webkitRequestAnimationFrame : any } & {
@@ -60,6 +61,7 @@ export const InfiniteLoading: FunctionComponent<
6061 onRefresh,
6162 onLoadMore,
6263 onScroll,
64+ defaultScrollTop,
6365 ...restProps
6466 } = {
6567 ...defaultProps ,
@@ -77,6 +79,16 @@ export const InfiniteLoading: FunctionComponent<
7779
7880 const classes = classNames ( classPrefix , className , `${ classPrefix } -${ type } ` )
7981
82+ useEffect ( ( ) => {
83+ if ( defaultScrollTop ) {
84+ const childHeight = ( getRefreshTop ( ) . firstElementChild as HTMLElement ) . offsetHeight || 0 ;
85+ refreshMaxH . current = Math . floor ( childHeight * 1 + 10 ) ;
86+ setTimeout ( ( ) => {
87+ scrollEl . current . scrollTop = defaultScrollTop
88+ } , 10 )
89+ }
90+ } , [ defaultScrollTop ] ) ;
91+
8092 useEffect ( ( ) => {
8193 if ( target && document . getElementById ( target ) ) {
8294 scrollEl . current = document . getElementById ( target )
You can’t perform that action at this time.
0 commit comments