Как я могу создать метод уничтожения для плагина, чтобы он не работал на мобильном телефоне? - PullRequest
0 голосов
/ 10 июля 2020

Мне нужно отключить следующий плагин, когда пользователь находится в мобильном браузере. Я думаю добавить метод уничтожения на основе ширины экрана, но не знаю, как это сделать.

    t.extend(e.prototype, {
        init: function() {
            var e = this.settings,
                s = t(this.element),
                i = s.prop("id").replace("-", "") || "stickr",
                n = e.closest ? s.closest(e.closest) : s.parent(),
                c = s.offset().top - n.offset().top - e.offsetTop;
            s.css("position", "relative"), e.closeButton === !0 && (s.append('<a class="close">' + e.closeChar + "</a>"), s.find(".close").css({
                position: "absolute",
                top: e.closeTop + "px",
                right: e.closeTop + "px"
            }), s.find(".close").on("click", function() {
                s.animate({
                    top: "0px"
                }, {
                    queue: e.queue,
                    easing: e.easing,
                    duration: e.duration
                }), t(o).off("scroll." + i), t(this).remove()
            })), t(o).on("scroll." + i, function() {
                t(o).scrollTop() > n.offset().top + c && n.height() + n.position().top + e.offsetBottom > t(o).scrollTop() + s.height() ? 0 === e.duration ? s.css("top", t(o).scrollTop() - (n.offset().top + c) + "px") : s.animate({
                    top: t(o).scrollTop() - (n.offset().top + c) + "px"
                }, {
                    queue: e.queue,
                    easing: e.easing,
                    duration: e.duration
                }) : t(o).scrollTop() < n.offset().top && s.animate({
                    top: "0px"
                }, {
                    queue: e.queue,
                    easing: e.easing,
                    duration: e.duration
                })
            })
        }
    }), t.fn[s] = function(o) {
        return this.each(function() {
            t.data(this, "plugin_" + s) || t.data(this, "plugin_" + s, new e(this, o))
        })
    }
...