How to disable the carousel swipe.js

I am trying to quickly convert a list of images to a carousel. I am using swipe.js (swipejs.com) libary as it works fine.

I want the carousel to start when the body width reaches less than 540 pixels, but vice versa, if the window is resized to a body width greater than 540 pixels, this will be canceled.

$(window).resize(function() { var bodyWidth = $('body').width(); if(bodyWidth < 540){ loadCarousel(); }else if(bodyWidth > 540) { unLoadCarousel(); } }); function loadCarousel() { window.deviceSwipe = new Swipe( document.getElementById('device-slider') ); } function unLoadCarousel() { } 

Now this is close to how I want (I believe), my real question is: how do I unload (disable?) This carousel and remove the inline styles that swipe.js includes?

I can use the following line to remove the styles, but this seems like a bit of work.

 $('#slider-container li, #slider-container ul, #device-slider').attr('style', '') 

This also does not stop swipe.js from simply reapplying styles when resizing the window (even if the size of the bodyWidth for some reason exceeds 540 pixels).

Any help would be greatly appreciated!

+4
source share
1 answer

You can use a method called kill, like deviceSwipe.kill ()

+2
source

All Articles