Skip to content
Mottie edited this page Apr 17, 2011 · 24 revisions

##AnythingSlider is starting from the last panel instead of the first. How do I fix it?

The problem is happening because AnythingSlider uses scrollLeft to position the slides in the viewport. When the Slider is hidden, as it would be in a popup, in a tab or inside an accordion, the scrollLeft value cannot be set and defaults to zero. So, here are three methods and an example on how to reset the correct panel position. This code must be called when the slider is visible.

  1. Instantly position the slider. This method may not work if the resizeContents option is set to false because panel width will vary.

     var s = $('#slider1').data('AnythingSlider');
     s.$window.scrollLeft( s.$window.width() + s.easingMargin );
    
  2. Animate into a specific slide

     $('#slider1').anythingSlider(1);
    
  3. Animate into the current slide

      var s = $('#slider1').data('AnythingSlider');
      s.gotoPage( s.currentPage );
    

Here is an example of an AnythingSlider that is used with a Facebox popup:

$(document).bind('reveal.facebox', function() {
  // go to first slide
  $('#facebox .anythingBase').anythingSlider(1);
});
Clone this wiki locally