$(document).ready(function() {
$('.owl-carousel').owlCarousel({ // .owl-carousel is the element selector
loop: true,
onResized: callback,
margin: 10, // gives space between carousel items
stagePadding: 20, // shows a bit of the next item, which is still not visible
responsiveBaseElement: '#owlarea',
responsive:{ // responsive behaviour
0:{
items:2
},
768:{ // for example at 768 screen width, owl carousel will only show two items
items:2
},
970:{
items:2
}
}
})
function callback() {
console.log('callback: onResized');
}
$(".btnres").click(function(){
$('#contentBox').toggleClass('open');
owlres();
//setTimeout(function() { owlres(); }, 500); // timeout
})
function owlres() {
//$('.owl-carousel').trigger('resize.owl');
$('.owl-carousel').trigger('resize.owl.carousel');
//$('.owl-carousel').trigger('refresh.owl');
$('.owl-carousel').trigger('refresh.owl.carousel');
//$('.owl-carousel').data('owlCarousel').refresh();
//$('.owl-carousel').owlCarousel('invalidate', 'all').owlCarousel('refresh');
// ALL THIS SH*T ^^ ACTIONS ^^ NOT WORKING!!!!
// THIS ACTIONS WORKING!!
//$('.owl-carousel').trigger('next.owl.carousel');
//$('.owl-carousel').trigger('destroy.owl');
// PATH FOR RESIZE ACTIONS BUT NOT WORKING IN IE
//window.dispatchEvent(new Event('resize'));
console.log('owlres');
}
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.