Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

owl-carousel only for mobile

/*
And a bit of CSS to show disabled Owl element:

.owl-carousel.off {
    display: block;
}
*/

$(function() {
    var owl = $('.owl-carousel'),

        owlOptions = {
          loop: false,
			    margin: 30,
			    smartSpeed: 700,
			    nav: false,
			    items: 1
        };

    if ( $(window).width() < 768 ) {
        var owlActive = owl.owlCarousel(owlOptions);
    } else {
        owl.addClass('off');
    }

    $(window).resize(function() {
        if ( $(window).width() < 768 ) {
            if ( $('.owl-carousel').hasClass('off') ) {
                var owlActive = owl.owlCarousel(owlOptions);
                owl.removeClass('off');
            }
        } else {
            if ( !$('.owl-carousel').hasClass('off') ) {
                owl.addClass('off').trigger('destroy.owl.carousel');
                owl.find('.owl-stage-outer').children(':eq(0)').unwrap();
            }
        }
    });
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript minimum number in array 
Javascript :: i18n react meta description 
Javascript :: js number to scientific notation 
Javascript :: javascript disable resize window 
Javascript :: How to remove title in material-table 
Javascript :: email id domain check javascript 
Javascript :: get the next character javascript 
Javascript :: javascript string to float 
Javascript :: jquery add multiple classes 
Javascript :: set min date field to current date 
Javascript :: replace text in string in javascript 
Javascript :: remove a user from a reaction discord.js 
Javascript :: boilerplate node js server 
Javascript :: jquery each tr except first 
Javascript :: check if input has value javascript 
Javascript :: remove duplicates in json array based on two fields in lodash 
Javascript :: sls invoke local 
Javascript :: how to get a record in dynamodb nodejs 
Javascript :: reverse string js 
Javascript :: contains substring javascript 
Javascript :: mongodb add new field 
Javascript :: get text from selected select javascript object 
Javascript :: parse csv javascript 
Javascript :: jquery forEach is not a function 
Javascript :: js for each item in array 
Javascript :: find one with specofoc id mongoose 
Javascript :: debounce react 
Javascript :: faker.js avatar 
Javascript :: find in string javascript 
Javascript :: json file with multiple records 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =