added vertical scroll to tabs

pull/1746/head
lianahus 3 years ago committed by yann300
parent f9a92f6eb8
commit 0b513b015b
  1. 18
      libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx
  2. 6342
      package-lock.json

@ -53,11 +53,29 @@ export const TabsUI = (props: TabsUIProps) => {
currentIndexRef.current = index
setSelectedIndex(index)
}
const scrollToNextTab = (event) => {
const next = event.deltaY > 0
let scrollTo = currentIndexRef.current
if (next) {
if (currentIndexRef.current < props.tabs.length - 1) {
scrollTo = currentIndexRef.current + 1
tabsRef.current[scrollTo].scrollIntoView({ behavior: 'smooth', block: 'center' })
}
} else {
if (currentIndexRef.current > 0) {
scrollTo = currentIndexRef.current - 1
tabsRef.current[scrollTo].scrollIntoView({ behavior: 'smooth', block: 'center' })
}
}
}
useEffect(() => {
props.onReady({
activateTab,
active
})
window.addEventListener('wheel', scrollToNextTab)
return () => { window.removeEventListener('wheel', scrollToNextTab) }
}, [])
return (

6342
package-lock.json generated

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save