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,
});
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!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.