You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From looking at the code, when the loop mode is active, a translate property gets added to keep the positions. The problem is this translate stops working when a break point is hit, and in turn everything jumps around - the duplicates push the active index out. If the active index is 1, then on a breakpoint hit, it could end up being -3 or -20, because of the padded duplicates.
This new mode would be something like "loopActive."
It would take slidesPerView and slidesPerMove. The logic of loop active would be to instead of translate modifying this as if it were a group, to instead use the slidesPerMove value as the jump value. So slideNext and slidePrev, triggered by anything, touch, mouswheel, navigation etc, would take into account the slidesPerMove value and slideToLoop + loopFix the value from slidesPerMove instead of just 1. The slidesPerView would be used just like it was before, to determine amount of slides visible.
By moving the logic out of actually grouping ie slidesPerGroup, the loopFix logic can work to reposition the entire track under the active. It would still be in loop mode, but only by a value of 1. When a breakpoint is hit in loop mode with a value of 1, the track moves by 1. Going from a breakpoint with slidersPerView of 3 to 4, will move the active index over by one. To fix this and keep its position while going through break point, on break point change it would need to run slideToLoop to the active index.
I almost had it working, but there's no access to loopFix - I had to manually run it from the console. The active slide is always the first.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The current loop mode doesn't work well with breakpoints.
#6113
From looking at the code, when the loop mode is active, a translate property gets added to keep the positions. The problem is this translate stops working when a break point is hit, and in turn everything jumps around - the duplicates push the active index out. If the active index is 1, then on a breakpoint hit, it could end up being -3 or -20, because of the padded duplicates.
This new mode would be something like "loopActive."
It would take
slidesPerView
andslidesPerMove
. The logic of loop active would be to instead of translate modifying this as if it were a group, to instead use theslidesPerMove
value as the jump value. SoslideNext
andslidePrev
, triggered by anything, touch, mouswheel, navigation etc, would take into account theslidesPerMove
value andslideToLoop
+loopFix
the value fromslidesPerMove
instead of just 1. TheslidesPerView
would be used just like it was before, to determine amount of slides visible.By moving the logic out of actually grouping ie
slidesPerGroup
, the loopFix logic can work to reposition the entire track under the active. It would still be in loop mode, but only by a value of 1. When a breakpoint is hit in loop mode with a value of 1, the track moves by 1. Going from a breakpoint withslidersPerView
of 3 to 4, will move the active index over by one. To fix this and keep its position while going through break point, on break point change it would need to runslideToLoop
to the active index.I almost had it working, but there's no access to loopFix - I had to manually run it from the console. The active slide is always the first.
Here's a sample:
https://codesandbox.io/s/broken-dawn-ljvj5l?file=/src/App.tsx:0-5642
Beta Was this translation helpful? Give feedback.
All reactions