-
Notifications
You must be signed in to change notification settings - Fork 379
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.
-
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 );
-
Animate into a specific slide
$('#slider1').anythingSlider(1);
-
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);
});