0

I'm looking for a way so that my js slider will change it's effect from (normal as it is now) to fade when my browser window is less than 800px. Can anybody help?

     <ul class="slider">

      <li><img src="images/1" alt="img" width="979" height="470"></li>
      <li><img src="images/2" alt="img" width="979" height="470"></li>
      <li><img src="images/3" alt="img" width="979" height="470"></li>

    </ul>

        $('.slider').bxSlider({
    navigation : true, 
        slideSpeed : 300,
        paginationSpeed : 400,  
        singleItem:true,

    });
Vladimir
  • 395
  • 1
  • 3
  • 7
  • What have you tried? use `$(window).width()` to get the width and check if its below 800 – Rodrigo Siqueira Oct 28 '13 at 12:11
  • i want it to look like this when i have width of less than 800px: $('.slider').bxSlider({ navigation : true, // Show next and prev buttons slideSpeed : 300, paginationSpeed : 400, singleItem:true, mode:'fade' }); – Vladimir Oct 28 '13 at 12:15
  • Use `var mode = $(window).width() > 800 ? 'default' : 'fade'` then use it in `mode` – Rodrigo Siqueira Oct 28 '13 at 12:18

1 Answers1

0

You could roll your own script to listen for resize events and then detect if the window is less than 800 pixels wide, but I would personally check out enquire.js for this particular problem. Using enquire.js your solution can be as easy as.

enquire.register("screen and (max-width:800px)", {

// OPTIONAL
// If supplied, triggered when a media query matches.
match : function() {

   //Code goes in here to change your slider to fade

},      

// OPTIONAL
// If supplied, triggered when the media query transitions 
// *from a matched state to an unmatched state*.
unmatch : function() {}

    //Code goes in here to set your slider transition type to normal

});

Hope that helps. Enquire has been an awesome tool for me!