CSS-Tricks / AnythingSlider

A jQuery Slider plugin for anything.

Home Page:http://css-tricks.github.io/AnythingSlider/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

undefined error when infiniteSlides = false and showMultiple = X

sarahkp opened this issue · comments

Hello,

I'm getting an undefined error from the getDim method:

Uncaught TypeError: Cannot read property '0' of undefined
at $.anythingSlider.base.getDim (jquery.anythingslider.js:570)

when I click a panel whose number is > than the startPanel setting, and when I have infiniteSlides set to false. This error does not occur when infiniteSlides is set to true.

I've downloaded the demo code from here, and have modified #slider1 options as follows:

showMultiple	: 2,
startPanel : 5,
resizeContents : false,
infiniteSlides : false,
easing : 'easeInOutBack',
navigationFormatter : function(index, panel){
  return ['Slab', 'Parking Lot', 'Drive', 'Glorius Dawn', 'Bjork?', 'Traffic Circle'][index - 1];
},
onSlideComplete : function(slider){
  // alert('Welcome to Slide #' + slider.currentPage);
}

I believe this is happening due to infiniteSlides being set to false, so no cloned panels are inside the base.panelSize[] array, making the array (sometimes) shorter than the max [t value] we're trying to access inside the o.showMultiple loop.

Do you have any suggestions for fixing this? I've set a condition so that if infinteSlides is false & page != 0, then page is set to 0 before the showMultiple loop begins inside getDim. This fixed the problem for me.

Thank you,
Sarah

Hi @sarahkp!

Thanks for reporting this problem. We haven't been doing much with this addon because there are newer and better alternatives out there; but because this was a bug I'll get it fixed for you!

Thanks @Mottie, I've updated my code with your fix.

Sarah