-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: scrollbar * refactor: merge func * chore: init hor prop * chore: xy * chore: scrollbar rtl * chore: size of it * chore: base rtl * chore: rtl * test: add test case * test: fix test case
- Loading branch information
Showing
9 changed files
with
526 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## horizontal scroll | ||
|
||
<code src="../../examples/horizontal-scroll.tsx"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import * as React from 'react'; | ||
import List from '../src/List'; | ||
|
||
interface Item { | ||
id: number; | ||
height: number; | ||
} | ||
|
||
const MyItem: React.ForwardRefRenderFunction<HTMLElement, Item> = ({ id, height }, ref) => { | ||
return ( | ||
<span | ||
ref={ref} | ||
style={{ | ||
border: '1px solid gray', | ||
padding: '0 16px', | ||
height, | ||
lineHeight: '30px', | ||
boxSizing: 'border-box', | ||
display: 'inline-block', | ||
whiteSpace: 'nowrap', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
}} | ||
> | ||
{id} {'longText '.repeat(100)} | ||
</span> | ||
); | ||
}; | ||
|
||
const ForwardMyItem = React.forwardRef(MyItem); | ||
|
||
const data: Item[] = []; | ||
for (let i = 0; i < 100; i += 1) { | ||
data.push({ | ||
id: i, | ||
height: 30, | ||
}); | ||
} | ||
|
||
const Demo = () => { | ||
const [rtl, setRTL] = React.useState(false); | ||
return ( | ||
<React.StrictMode> | ||
<div> | ||
<button | ||
onClick={() => { | ||
setRTL(!rtl); | ||
}} | ||
> | ||
RTL: {String(rtl)} | ||
</button> | ||
|
||
<div style={{ width: 500, margin: 64 }}> | ||
<List | ||
direction={rtl ? 'rtl' : 'ltr'} | ||
data={data} | ||
height={300} | ||
itemHeight={30} | ||
itemKey="id" | ||
scrollWidth={2328} | ||
// scrollWidth={100} | ||
style={{ | ||
border: '1px solid red', | ||
boxSizing: 'border-box', | ||
}} | ||
onScroll={(e) => { | ||
console.log('Scroll:', e); | ||
}} | ||
> | ||
{(item) => <ForwardMyItem {...item} />} | ||
</List> | ||
</div> | ||
</div> | ||
</React.StrictMode> | ||
); | ||
}; | ||
|
||
export default Demo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.