fix(dashboard-v2): fix slider scrolling to far when window size is increased on the last slide
This commit is contained in:
parent
92892bf2d2
commit
7adbc4bf68
|
@ -38,6 +38,15 @@ const Slider = ({ slides, breakpoints }) => {
|
||||||
[slides, visibleSlides, setActiveIndex]
|
[slides, visibleSlides, setActiveIndex]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
const maxIndex = slides.length - visibleSlides;
|
||||||
|
|
||||||
|
// Make sure to not scroll too far when screen size changes.
|
||||||
|
if (activeIndex > maxIndex) {
|
||||||
|
setActiveIndex(maxIndex);
|
||||||
|
}
|
||||||
|
}, [slides.length, visibleSlides, activeIndex]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<Scroller
|
<Scroller
|
||||||
|
|
Reference in New Issue