Wrong order calculation for multi-lines container
See original GitHub issueIn case if not all lines are full filled up the Swiper generate wrong source number. For example you can try 16 items, slidesPerColumn: 3, slidesPerColumnFill: ‘column’ in case if 6 columns are visible. Proposed fix is (core.js, starting in line 515:)
// Calc slides
var slideSize;
var slidesPerColumn = s.params.slidesPerColumn;
var slidesPerRow = slidesNumberEvenToRows / slidesPerColumn;
var numFullColumns = slidesPerRow - (s.params.slidesPerColumn * slidesPerRow - s.slides.length);
for (i = 0; i < s.slides.length; i++) {
slideSize = 0;
var slide = s.slides.eq(i);
if (s.params.slidesPerColumn > 1) {
// Set slides order
var newSlideOrderIndex;
var column, row;
if (s.params.slidesPerColumnFill === 'column') {
column = Math.floor(i / slidesPerColumn);
row = i - column * slidesPerColumn;
if (column > numFullColumns || (column==numFullColumns && row==slidesPerColumn-1)) {
if (++row>=slidesPerColumn) {
row=0;
column++;
}
}
newSlideOrderIndex = column + row * slidesPerRow;
slide
.css({
'-webkit-box-ordinal-group': newSlideOrderIndex,
'-moz-box-ordinal-group': newSlideOrderIndex,
'-ms-flex-order': newSlideOrderIndex,
'-webkit-order': newSlideOrderIndex,
'order': newSlideOrderIndex
});
}
else {
row = Math.floor(i / slidesPerRow);
column = i - row * slidesPerRow;
}
slide
.css({
'margin-top': (row !== 0 && s.params.spaceBetween) && (s.params.spaceBetween + 'px')
})
.attr('data-swiper-column', column)
.attr('data-swiper-row', row);
}
…
Thank you, -=A=-
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
`scalebox` scales the equation number in a multiline equation ...
First of all: I agree with Bernard's comment that scaling an equation is usually a bad idea. In my experience of long, horrible...
Read more >Split Multiple Lines in a Cell into Separate Cells - YouTube
Download the feature file here: https://www.bluepecantraining.com/exc... In this video I demonstrate how to split multiple lines within a ...
Read more >Measure height of multi-line TextView before rendering
Your solution is OK but it fails to work on my side, as I need the height to be calculated immediately once the...
Read more >Multi-Line Truncation with Pure CSS
Truncating multiple lines is a bit harder. ... The trick there is to make a little box that is the same background as...
Read more >How to enter multiple lines in one cell in Excel 2021 - Ablebits
You can write an Excel formula on multiple lines. Reply. Savan says: December 25, 2022 at 10:55 pm. When ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have found a solution to this problem for my project. The problem seems to occur because of how CSS flexbox works with Swiper. It still fills the slides by row, and column is only simulated by using CSS order, so the last remaining items always show on the last row, instead of in the last column.
My solution is to calculate how many slides are missing to fill the whole grid, then append placeholder empty slides equal to number of missing slides to Swiper on init, and then Swiper will calculate and fill the columns correctly.
Code I’m using is here:
Hope something like this can be implemented in core to solve the problem with filling columns correctly.
Live example can be found here: https://www.myresjohus.se/inspiration/hall/
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.