jeudi 19 août 2021

If/else statement inside jQuery object array

I have this array of objects. I want the value of 'duration' to change based on the width of the screen with an if/else statement.

This is what I've got right now, but I can't get it to work. I think it's because of the variable?

($.fn.defaults = {
    items: { start: 0 },
    scroll: {
        easing: "swing",
        duration: function (fztime) {
            var fztime;
            $(window).resize(function() {
                if($(window).width() >= 641) {
                    fztime = 7000;
                } else {
                    fztime = 500;
                }
            }).resize()
        },
        pauseOnHover: !1,
        event: "click",
        queue: !1 }
})

Aucun commentaire:

Enregistrer un commentaire