-
-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add new prop scrollPosition #756
Open
OysterD3
wants to merge
10
commits into
react-component:master
Choose a base branch
from
OysterD3:feat/scroll-position
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+138
−17
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9cbd9e6
feat: add tab scroll
OysterD3 246ec4f
chore: add docs
OysterD3 3fd06e4
refactor: add setTimeout
OysterD3 7abb2ec
feat: add scrollPosition as deps
OysterD3 5458709
chore: add vertical demo
OysterD3 48ffbbd
chore: add api to readme
OysterD3 5739d25
revert commit
OysterD3 d7537b5
chore: update demo
OysterD3 15ce46d
fix: remove settimeout
OysterD3 0078378
chore: update readme
OysterD3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,8 @@ | ||
--- | ||
title: scroll-position | ||
nav: | ||
title: Demo | ||
path: /demo | ||
--- | ||
|
||
<code src="../examples/scroll-position.tsx"></code> |
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,76 @@ | ||
import type { ScrollPosition } from '@/interface'; | ||
import React from 'react'; | ||
import '../../assets/index.less'; | ||
import type { TabsProps } from '../../src'; | ||
import Tabs from '../../src'; | ||
|
||
const items: TabsProps['items'] = []; | ||
for (let i = 0; i < 50; i += 1) { | ||
items.push({ | ||
key: String(i), | ||
label: `Tab ${i}`, | ||
children: `Content of ${i}`, | ||
}); | ||
} | ||
export default () => { | ||
const [scrollPosition, setScrollPosition] = React.useState<ScrollPosition>('end'); | ||
|
||
return ( | ||
<> | ||
<div style={{ marginBottom: 10, display: 'flex', gap: 10 }}> | ||
<label> | ||
Start | ||
<input | ||
type="radio" | ||
name="scrollPosition" | ||
value="start" | ||
checked={scrollPosition === 'start'} | ||
onChange={e => setScrollPosition(e.target.value as ScrollPosition)} | ||
/> | ||
</label> | ||
<label> | ||
Center | ||
<input | ||
type="radio" | ||
name="scrollPosition" | ||
value="center" | ||
checked={scrollPosition === 'center'} | ||
onChange={e => setScrollPosition(e.target.value as ScrollPosition)} | ||
/> | ||
</label> | ||
<label> | ||
End | ||
<input | ||
type="radio" | ||
name="scrollPosition" | ||
value="end" | ||
checked={scrollPosition === 'end'} | ||
onChange={e => setScrollPosition(e.target.value as ScrollPosition)} | ||
/> | ||
</label> | ||
<label> | ||
Auto | ||
<input | ||
type="radio" | ||
name="scrollPosition" | ||
value="auto" | ||
checked={scrollPosition === 'auto'} | ||
onChange={e => setScrollPosition(e.target.value as ScrollPosition)} | ||
/> | ||
</label> | ||
</div> | ||
<div style={{ maxWidth: 550 }}> | ||
<Tabs items={items} scrollPosition={scrollPosition} /> | ||
</div> | ||
|
||
<div style={{ maxHeight: 550 }}> | ||
<Tabs | ||
style={{ height: 550 }} | ||
items={items} | ||
scrollPosition={scrollPosition} | ||
tabPosition="left" | ||
/> | ||
</div> | ||
</> | ||
); | ||
}; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个部分有点多余,因为useEffect里每当activeKey更换的时候会触发scrollToTab,所以没必要在这里触发多一次