Skip to content

Commit

Permalink
♻️ refactor conditional rendering of navigation buttons (#1373)
Browse files Browse the repository at this point in the history
  • Loading branch information
SvSven committed Jan 3, 2023
1 parent 79726f7 commit 4832f30
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions web/pageComponents/shared/Carousel/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,13 @@ export const NavButton = ({ type }: { type: 'prev' | 'next' }) => {
})
}

swiper.on('slideChange', (swipe) => {
updateConfig(swipe)
})
swiper.on('lock', (swipe) => {
updateConfig(swipe)
})
swiper.on('unlock', (swipe) => {
updateConfig(swipe)
})
swiper.on('transitionStart', (swipe) => {
updateConfig(swipe)
})
swiper.on('transitionEnd', (swipe) => {
updateConfig(swipe)
})
swiper.on('reachBeginning', (swipe) => updateConfig(swipe))
swiper.on('reachEnd', (swipe) => updateConfig(swipe))

return () => {
swiper.off('reachBeginning', (swipe) => updateConfig(swipe))
swiper.off('reachEnd', (swipe) => updateConfig(swipe))
}
}, [swiper])

if (type !== 'prev' && type !== 'next') return null
Expand Down

0 comments on commit 4832f30

Please sign in to comment.