Deactivate Slide Show #85

Closed
asab5241 opened this Issue May 16, 2011 · 2 comments

Projects

None yet

2 participants

@asab5241

I am trying to find a way to disable or deactivate an already initialized Slider. I want to give a user the option of turning off the slider to make a "list all" kind of feature (all the slides just basically turn back to their original html forms). I would also want to have a way to re-enable it again. A toggle switch basically.

Is there an easy way to achieve this using the slider?

Any help would be greatly appreciated.

@Mottie
Member
Mottie commented May 16, 2011

Hi asab5241!

I made a demo (http://jsfiddle.net/Mottie/JMgeC/346/) which basically removes the class names so the stylesheet isn't applied. Then reapplies them after you click the activate button. Now, this keeps all functionality intact, so if you added a lightbox that pops up when the image is clicked, that will still work. Here is the code I used in the demo:

// Activate
$('button:first').click(function(){
    var s = $('#slider')
    s.addClass('anythingBase');
    s.parent().addClass('anythingWindow');
    s.parent().parent()
        .addClass('anythingSlider')
        .find('.anythingControls, .arrow, .cloned').show();
});

// Deactivate
$('button:last').click(function(){
    var s = $('#slider');
    s.data('AnythingSlider').startStop(false); // stops the slideshow
    s.removeClass('anythingBase');
    s.parent().removeClass('anythingWindow');
    s.closest('.anythingSlider')
        .removeClass('anythingSlider')
        .find('.anythingControls, .arrow, .cloned').hide();
});

If you need AnythingSlider to be completely disabled, then I'd have to add a destroy method or something and it'll take a bit more coding.

@Mottie
Member
Mottie commented May 17, 2011

I'm going to go ahead and close this issue. If you need something more than what I have above, please feel free to reopen the issue and leave a comment :)

@Mottie Mottie closed this May 17, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment