Answer the question
In order to leave comments, you need to log in
How to make an infinite sectional horizontal scroll?
I'm trying to make an infinite horizontal scroll for a calendar. Currently available:
<div className="parent">
{state.map ((_, i) => <div />)}
</div>
.parent {
display: flex;
width: 100%;
overflow-x: scroll;
overflow-y: hidden;
scroll-snap-type: x mandatory;
touch-action: pan-x;
}
.parent div {
width: 100%;
height: 100%;
scroll-snap-align: center;
}
useEffect (() => {
setInterval (() => {
setState (state => {
state.push (1);
return [...state];
});
}, 2000);
}, []);
Answer the question
In order to leave comments, you need to log in
Use transform to position blocks, and position each one properly. Without adding/removing elements at the beginning or at the end.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question