question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

returnIndex value not correct on multiple slides

See original GitHub issue

Heya! Like I already mentioned on Twitter: Love the slider and lack of compromises to make it nice and modern. Also loving the events, but I do have a question on those though.

I make a lot of use of returnIndex, but it seems that it doesn’t return the right number in the following case:

When you have a slider with multiple items to slide, i.e. ‘slidesToScroll:4’ but an amount of slides that doesn’t fill out the entire slider, i.e. 10. In this case you’d have 3 ‘pages’, two with 4 items and one with 2 items. Unfortunately, on the last page, the ‘active’ class stays stuck on the 5th item (returnIndex = 4) which makes little sense to me as this is out of the viewport. Also, it makes that clicking the back button slides back from slide #5 instead of #9, resulting in a weird slide back (one click vs the expected 2) If I up the amount of slides to 12 the behaviour is as expected.

Is this intended or might this be a bug?

Thanks for your time!

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
riotckucommented, Jun 8, 2016

I have a similar issue, but a simpler one.

When I use returnIndex() at the last slide (length - 1) with the rewind option as true, I get the wrong index, specifically it returns the index of the previous slide. If this is a separate bug from this issue, please let me know and I’ll make a separate issue.

0reactions
mikemaccanacommented, Jun 13, 2018

Same here. I’m just hacking it for now - long term it would be better to move away from inline-block completely - slides aren’t really blocks inside a line of characters - and just use grid, now most people are on an evergreen browser.

// HACK
// 1050 highlights last item but no rewind
// 1025 doesn't highlight last item
// See https://github.com/meandmax/lory/issues/197
const FIX_BUG = 1040

const maxOffset = Math.round(slidesWidth - frameWidth) + FIX_BUG;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple ion-slides in loop not providing correct index on slides
The issue is that you have multiple instances of an ion-slider in your view but ViewChild is used to get only one instance...
Read more >
getActiveIndex() returning wrong index · Issue #7616 - GitHub
I setup a simple 4 images sliders, however I see several issues. <ion-slides [options]="mySlideOptions" #mySlider (ionDidChange)=SlideChanged()> <ion-slide> <h1> ...
Read more >
Look up values with VLOOKUP, INDEX, or MATCH
Use VLOOKUP, HLOOKUP, and other functions like INDEX and MATCH to search for and find data based on values you enter. This article...
Read more >
INDEX - Google Docs Editors Help
Returns the cell(s) found by index value into the referenced range. Sample Usage. INDEX(A1:C20, 5, 1). Syntax. INDEX(reference, [row], [column]).
Read more >
How to use the INDEX function in Google Sheets - Sheetgo Blog
The INDEX function in Google Sheets returns the value of a cell within an input ... So no matter how many weeks you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found