forked from Adleraci/adlerka.top
595 lines
29 KiB
JavaScript
595 lines
29 KiB
JavaScript
(() => {
|
|
"use strict";
|
|
(() => {
|
|
function getDom(t) {
|
|
return function hasDom(t) {
|
|
return null !== document.querySelector(t)
|
|
}(t) ? document.querySelector(t) : null
|
|
}
|
|
|
|
function setDom(t) {
|
|
for (var e, n = document.createElement(t), o = arguments.length, i = new Array(o > 1 ? o - 1 : 0), r = 1; r < o; r++) i[r - 1] = arguments[r];
|
|
return (e = n.classList).add.apply(e, i), n
|
|
}
|
|
|
|
function findDom(t, e) {
|
|
try {
|
|
return t.querySelector(e)
|
|
} catch (t) {
|
|
return null
|
|
}
|
|
}
|
|
|
|
var t = "sliderm", e = "sliderm__slides", n = "sliderm__paginations", o = "sliderm__pagination",
|
|
i = "sliderm__slide--clone";
|
|
|
|
function isInteger(t) {
|
|
return Number.isFinite(t)
|
|
}
|
|
|
|
var r = function bold(t) {
|
|
var e = {1: "thin", 2: "regular", 3: "bold"};
|
|
return void 0 !== e[t] ? e[t] : "regular"
|
|
}, a = function shape(t) {
|
|
return "none" === t || "square" === t ? t : "circle"
|
|
}, s = function size(t) {
|
|
return isInteger(t) && 16 !== t ? t <= 13 ? 13 : t >= 28 ? 28 : t : null
|
|
}, l = function bgColor(t) {
|
|
return "#000000" !== t ? t : null
|
|
}, u = function color(t) {
|
|
return "#ffffff" !== t ? t : null
|
|
}, c = function opacity(t) {
|
|
return !isInteger(t) || t > 1 || t < .1 || .5 === t ? null : t
|
|
};
|
|
|
|
function queue(t) {
|
|
var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0;
|
|
return setTimeout((function () {
|
|
t()
|
|
}), e)
|
|
}
|
|
|
|
var p = [function breakpoint(t, e) {
|
|
if (t.getOption("breakpoint")) {
|
|
!function init() {
|
|
var n = t.getOption("columns"), o = t.getOption("breakpoint.columns"),
|
|
i = Number(e.getAttribute("data-columns")), r = function calculate(t, e) {
|
|
var n = window.innerWidth, o = Object.keys(t).filter((function (e) {
|
|
return n < t[e]
|
|
}));
|
|
return void 0 !== o[0] ? Number(o[0]) : e
|
|
}(o, n);
|
|
if (e.setAttribute("data-columns", n), void 0 !== r && i !== r) {
|
|
var a = t.getItems();
|
|
t.updateOption("columns", r), t.updateCurrentItems();
|
|
for (var s = 0; s < a.length; s += 1) t.go("columns", a[s]);
|
|
t.emit("breakpoint.changed")
|
|
}
|
|
}()
|
|
}
|
|
}, function transition(t, e) {
|
|
for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), i = 2; i < n; i++) o[i - 2] = arguments[i];
|
|
var r = o[0], a = t.getOption("duration");
|
|
"stop" !== r ? (e.style.setProperty("transition-duration", "".concat(a, "ms")), t.on("destory", (function () {
|
|
e.style.removeProperty("transition-duration")
|
|
}))) : e.style.removeProperty("transition-duration")
|
|
}, function transform(t, e) {
|
|
for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), i = 2; i < n; i++) o[i - 2] = arguments[i];
|
|
var r = o[0];
|
|
e.style.setProperty("transform", "translateX(".concat(r, "px)")), t.on("destory", (function () {
|
|
e.style.removeProperty("transform")
|
|
}))
|
|
}, function autoplay(t) {
|
|
if (t.getOption("autoplay")) {
|
|
var e = t.getOption("autoplay.duration"), n = "left" === t.getOption("autoplay.direction") ? "<" : ">",
|
|
o = function repeat(t) {
|
|
return setInterval((function () {
|
|
t()
|
|
}), arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 5e3)
|
|
}((function () {
|
|
t.slideTo(n)
|
|
}), e);
|
|
t.on("destory", (function () {
|
|
!function stop(t) {
|
|
clearInterval(t), clearTimeout(t)
|
|
}(o)
|
|
}))
|
|
}
|
|
}, function grouping(t, e) {
|
|
for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), i = 2; i < n; i++) o[i - 2] = arguments[i];
|
|
var r = o[0], a = o[1], s = t.getOption("grouping"), l = a + 1;
|
|
if (s) {
|
|
var u = t.getOption("columns"), c = Math.ceil((a + 1) / u);
|
|
r.setAttribute("data-order", c)
|
|
} else r.setAttribute("data-order", l);
|
|
t.on("destory", (function () {
|
|
r.removeAttribute("data-order")
|
|
}))
|
|
}, function columns(t, e) {
|
|
for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), i = 2; i < n; i++) o[i - 2] = arguments[i];
|
|
var r = o[0], a = t.getOption("columns"), s = parseFloat((1 / a * 100).toFixed(2));
|
|
r.style.setProperty("flex", "0 0 ".concat(s, "%")), t.on("destory", (function () {
|
|
r.style.removeProperty("flex")
|
|
}))
|
|
}, function preview(t, e) {
|
|
if (t.getOption("preview")) {
|
|
var n = t.getOption("preview.edge");
|
|
e.style.setProperty("padding", "0 ".concat(n, "px")), t.on("destory", (function () {
|
|
e.style.removeProperty("padding")
|
|
}))
|
|
}
|
|
}, function spacing(t, e) {
|
|
for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), i = 2; i < n; i++) o[i - 2] = arguments[i];
|
|
var r = o[0], a = Math.floor(t.getOption("spacing") / 2);
|
|
r.style.setProperty("padding", "0px ".concat(a, "px")), t.on("destory", (function () {
|
|
r.style.removeProperty("padding")
|
|
}))
|
|
}, function align(t, e) {
|
|
var n = t.getOption("align");
|
|
"center" === n ? e.style.setProperty("align-items", "center") : "bottom" === n && e.style.setProperty("align-items", "flex-end"), t.on("destory", (function () {
|
|
e.style.removeProperty("align-items")
|
|
}))
|
|
}, function touch(t, e) {
|
|
if (t.getOption("touch")) {
|
|
!function init() {
|
|
var n = t.getOption("touch.threshold"), o = t.getOption("touch.duration"), i = t.adaptEvent(e),
|
|
r = {x: 0, y: 0, time: 0};
|
|
i.on("touchstart", (function (t) {
|
|
t.preventDefault();
|
|
var e = t.changedTouches[0];
|
|
r.x = e.pageX, r.y = e.pageY, r.time = (new Date).getTime()
|
|
})), i.on("touchmove", (function (t) {
|
|
t.preventDefault()
|
|
})), i.on("touchend", (function (e) {
|
|
e.preventDefault();
|
|
var i = e.changedTouches[0], a = (new Date).getTime() - r.time, s = Math.abs(i.pageX - r.x);
|
|
if (!(a > o || s < n)) {
|
|
var l = i.pageX > r.x ? ">" : "<";
|
|
t.slideTo(l)
|
|
}
|
|
}))
|
|
}()
|
|
}
|
|
}, function clone(t, e) {
|
|
for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), r = 2; r < n; r++) o[r - 2] = arguments[r];
|
|
var a = o[0], s = o[1], l = t.getOption("columns"), u = t.getOption("preview"), c = t.getOption("loop");
|
|
if (u || c) {
|
|
var p = t.getItemCount(), d = t.getItems(), f = l, h = a.cloneNode(!0), v = null, m = !1;
|
|
h.classList.add(i), s < f && (e.appendChild(h), m = !0), s >= p - f && (m ? ((v = a.cloneNode(!0)).classList.add(i), e.insertBefore(v, d[0])) : e.insertBefore(h, d[0])), t.on("destory", (function () {
|
|
h.remove(), v && v.remove()
|
|
}))
|
|
}
|
|
}, function slide(t, e) {
|
|
for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), i = 2; i < n; i++) o[i - 2] = arguments[i];
|
|
var r = o[0], a = o[1], s = t.getOption("grouping"), l = t.getOption("preview"),
|
|
u = t.getOption("duration"), c = t.getOption("columns"), p = t.getOption("loop"),
|
|
d = t.getItems()[0].offsetWidth, f = t.getPage(), h = p || l, v = f.maximum(), m = f.calculate(r, !1),
|
|
g = m < 1 || m > v, y = 0;
|
|
!p && g || (y = s ? d * (0 - (h ? 0 : -1) - m) * c : d * (1 - (h ? c : 0) - m), t.emit("slide.start"), t.go("transition", a), t.go("transform", y), t.updatePosition(m), g ? queue((function () {
|
|
m = f.calculate(r, g), y = s ? d * (0 - m) * c : d * (1 - c - m), t.go("transition", "stop"), t.go("transform", y), t.updatePosition(m), t.emit("slide.end")
|
|
}), u + 10) : t.emit("slide.end"))
|
|
}, function loop(t, e) {
|
|
var n = t.getOption("loop"), o = t.getOption("grouping");
|
|
if (n && o) {
|
|
var i = t.getItems(), r = t.getOption("columns"), a = t.getItemCount(), s = i[i.length - 1],
|
|
l = r - a % r, u = [];
|
|
if (l !== r && 1 !== r) {
|
|
for (var c = 1; c <= l; c += 1) {
|
|
var p = s.cloneNode(!0);
|
|
p.classList.add("sliderm__slide--empty"), p.innerHTML = "", e.appendChild(p), u.push(p)
|
|
}
|
|
t.updateCurrentItems(), t.on("destory", (function () {
|
|
u.forEach((function (t) {
|
|
t.remove()
|
|
}))
|
|
}))
|
|
}
|
|
}
|
|
}, function init(e) {
|
|
var n = e.getOption("duration"), o = e.getRoot();
|
|
o.classList.add(t), o.classList.remove("".concat(t, "--initialized")), o.classList.add("".concat(t, "--initialize")), e.on("initialized", (function () {
|
|
queue((function () {
|
|
o.classList.remove("".concat(t, "--initialize")), o.classList.add("".concat(t, "--initialized"))
|
|
}), n + 50)
|
|
}))
|
|
}], d = [function pagination(t) {
|
|
var e, i, r, a = function click(e) {
|
|
if (o === e.target.className) {
|
|
var n = Array.prototype.indexOf.call(i.childNodes, e.target) + 1;
|
|
t.slideTo(n)
|
|
}
|
|
}, s = function mark() {
|
|
var e = t.getPosition(), o = findDom(t.getRoot(), ".".concat(n)).children;
|
|
Array.from(o).forEach((function (t, n) {
|
|
var o = n + 1;
|
|
t.removeAttribute("data-active"), o === e && t.setAttribute("data-active", !0)
|
|
}))
|
|
}, l = function destory() {
|
|
r.off("click", a), t.off("slide.end", s), i.remove()
|
|
}, u = function init() {
|
|
!function render() {
|
|
var a = setDom("div", n);
|
|
e = t.getPage().maximum();
|
|
for (var s = 0; s < e; s += 1) {
|
|
var l = setDom("div", o);
|
|
0 === s && l.setAttribute("data-active", !0), a.append(l)
|
|
}
|
|
i = a, r = t.adaptEvent(i), t.getRoot().append(i)
|
|
}(), function listen() {
|
|
r.on("click", a), t.on("slide.end", s)
|
|
}()
|
|
};
|
|
t.on("destory", l), t.on("breakpoint.changed", (function () {
|
|
l(), u()
|
|
})), u()
|
|
}, function spinner(t) {
|
|
!function init() {
|
|
var e = t.getOption("spinner.color"), n = setDom("div", "sliderm__spinner");
|
|
n.style.setProperty("color", e), t.getRoot().append(n), t.on("destory", (function () {
|
|
n.remove()
|
|
}))
|
|
}()
|
|
}, function arrow(t) {
|
|
!function init() {
|
|
for (var e = [s, r, a, u, l, c], n = setDom("div", "sliderm__button--previous"), o = setDom("div", "sliderm__button--next"), i = t.adaptEvent(n), p = t.adaptEvent(o), d = null, f = null, h = 0; h < e.length; h += 1) {
|
|
var v = e[h].name, m = e[h](t.getOption("arrow.".concat(v)));
|
|
null !== m && ("bold" === v ? (d = setDom("span", "sliderm__icon-left--".concat(m)), f = setDom("span", "sliderm__icon-right--".concat(m))) : "shape" === v ? (n.classList.add("sliderm__button--".concat(m)), o.classList.add("sliderm__button--".concat(m))) : ("bgColor" === v ? v = "background-color" : "size" === v && (v = "font-size", m = "".concat(m, "px")), n.style.setProperty(v, m), o.style.setProperty(v, m)))
|
|
}
|
|
n.append(d), o.append(f), t.getRoot().append(n), t.getRoot().append(o), i.on("click", (function () {
|
|
t.slideTo("<")
|
|
})), p.on("click", (function () {
|
|
t.slideTo(">")
|
|
})), t.on("destory", (function () {
|
|
n.remove(), o.remove()
|
|
}))
|
|
}()
|
|
}];
|
|
|
|
function _defineProperties(t, e) {
|
|
for (var n = 0; n < e.length; n++) {
|
|
var o = e[n];
|
|
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o)
|
|
}
|
|
}
|
|
|
|
var f = function () {
|
|
function EventDispatcher() {
|
|
!function _classCallCheck(t, e) {
|
|
if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function")
|
|
}(this, EventDispatcher), this.events = {}
|
|
}
|
|
|
|
return function _createClass(t, e, n) {
|
|
return e && _defineProperties(t.prototype, e), n && _defineProperties(t, n), Object.defineProperty(t, "prototype", {writable: !1}), t
|
|
}(EventDispatcher, [{
|
|
key: "on", value: function on(t, e) {
|
|
Object.prototype.hasOwnProperty.call(this.events, t) || (this.events[t] = []), this.events[t].push(e)
|
|
}
|
|
}, {
|
|
key: "off", value: function off(t, e) {
|
|
var n = this;
|
|
void 0 === e ? delete this.events[t] : this.events[t].forEach((function (o, i) {
|
|
o === e && n.events[t].splice(i, 1)
|
|
}))
|
|
}
|
|
}, {
|
|
key: "emit", value: function emit(t) {
|
|
for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++) n[o - 1] = arguments[o];
|
|
void 0 !== this.events[t] && Array.isArray(this.events[t]) && this.events[t].forEach((function (t) {
|
|
t.apply(void 0, n)
|
|
}))
|
|
}
|
|
}, {
|
|
key: "destory", value: function destory() {
|
|
delete this.events
|
|
}
|
|
}]), EventDispatcher
|
|
}();
|
|
|
|
function event_adapter_defineProperties(t, e) {
|
|
for (var n = 0; n < e.length; n++) {
|
|
var o = e[n];
|
|
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o)
|
|
}
|
|
}
|
|
|
|
var h = function () {
|
|
function EventAdapter(t) {
|
|
!function event_adapter_classCallCheck(t, e) {
|
|
if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function")
|
|
}(this, EventAdapter), this.target = t, this.events = {}
|
|
}
|
|
|
|
return function event_adapter_createClass(t, e, n) {
|
|
return e && event_adapter_defineProperties(t.prototype, e), n && event_adapter_defineProperties(t, n), Object.defineProperty(t, "prototype", {writable: !1}), t
|
|
}(EventAdapter, [{
|
|
key: "on", value: function on(t, e) {
|
|
this.events[t] = e, this.target.addEventListener(t, this.events[t])
|
|
}
|
|
}, {
|
|
key: "off", value: function off(t) {
|
|
this.target.removeEventListener(t, this.events[t])
|
|
}
|
|
}, {
|
|
key: "emit", value: function emit(t) {
|
|
void 0 !== this.events[t] && this.target.dispatchEvent(new Event(t))
|
|
}
|
|
}, {
|
|
key: "destory", value: function destory() {
|
|
for (var t = Object.keys(this.events), e = 0; e < t.length; e += 1) this.off(t[e]);
|
|
delete this.events
|
|
}
|
|
}, {
|
|
key: "mock", value: function mock(t, e) {
|
|
void 0 !== this.events[t] && this.events[t](e)
|
|
}
|
|
}]), EventAdapter
|
|
}();
|
|
|
|
function error(t) {
|
|
console.error("[Sliderm] ".concat(t))
|
|
}
|
|
|
|
const v = {
|
|
arrow: !0,
|
|
pagination: !0,
|
|
spinner: !0,
|
|
grouping: !1,
|
|
loop: !0,
|
|
preview: !1,
|
|
breakpoint: !0,
|
|
touch: !0,
|
|
autoplay: !1,
|
|
columns: 4,
|
|
duration: 1e3,
|
|
spacing: 10,
|
|
align: "center",
|
|
extensions: [],
|
|
_arrow: {color: "#ffffff", bgColor: "#000000", opacity: .5, size: 16, shape: "circle", bold: 2},
|
|
_preview: {edge: 40},
|
|
_spinner: {color: "#1cbbb4"},
|
|
_breakpoint: {columns: {4: !1, 3: 960, 2: 768, 1: 420}},
|
|
_touch: {threshold: 10, duration: 300},
|
|
_autoplay: {direction: "right", duration: 5e3}
|
|
};
|
|
|
|
function page_defineProperties(t, e) {
|
|
for (var n = 0; n < e.length; n++) {
|
|
var o = e[n];
|
|
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o)
|
|
}
|
|
}
|
|
|
|
var m = function () {
|
|
function Page(t) {
|
|
!function page_classCallCheck(t, e) {
|
|
if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function")
|
|
}(this, Page), this.sliderm = t
|
|
}
|
|
|
|
return function page_createClass(t, e, n) {
|
|
return e && page_defineProperties(t.prototype, e), n && page_defineProperties(t, n), Object.defineProperty(t, "prototype", {writable: !1}), t
|
|
}(Page, [{
|
|
key: "calculate", value: function calculate() {
|
|
for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++) e[n] = arguments[n];
|
|
var o = e[0], i = e[1], r = this.sliderm.getOption("columns"),
|
|
a = this.sliderm.getOption("grouping"), s = this.sliderm.getItemCount(),
|
|
l = this.sliderm.getGroupCount(), u = this.sliderm.getPosition(), c = a ? l : s, p = u, d = 0;
|
|
if (a) {
|
|
var f = Math.ceil(u * r / r);
|
|
p = f
|
|
}
|
|
return "number" == typeof o ? d = o : ">" === o ? (d = p + 1) > c && i && (d = 1) : "<" === o && (d = p - 1) <= 0 && i && (d = c), d
|
|
}
|
|
}, {
|
|
key: "maximum", value: function maximum() {
|
|
var t = this.sliderm.getOption("loop"), e = this.sliderm.getOption("preview"),
|
|
n = this.sliderm.getOption("grouping"), o = this.sliderm.getOption("columns"), i = t || e;
|
|
return n ? this.sliderm.getGroupCount() : i ? this.sliderm.getItemCount() : this.sliderm.getItemCount() - o + 1
|
|
}
|
|
}]), Page
|
|
}();
|
|
|
|
function _toConsumableArray(t) {
|
|
return function _arrayWithoutHoles(t) {
|
|
if (Array.isArray(t)) return _arrayLikeToArray(t)
|
|
}(t) || function _iterableToArray(t) {
|
|
if ("undefined" != typeof Symbol && null != t[Symbol.iterator] || null != t["@@iterator"]) return Array.from(t)
|
|
}(t) || _unsupportedIterableToArray(t) || function _nonIterableSpread() {
|
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
|
|
}()
|
|
}
|
|
|
|
function _slicedToArray(t, e) {
|
|
return function _arrayWithHoles(t) {
|
|
if (Array.isArray(t)) return t
|
|
}(t) || function _iterableToArrayLimit(t, e) {
|
|
var n = null == t ? null : "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"];
|
|
if (null == n) return;
|
|
var o, i, r = [], a = !0, s = !1;
|
|
try {
|
|
for (n = n.call(t); !(a = (o = n.next()).done) && (r.push(o.value), !e || r.length !== e); a = !0) ;
|
|
} catch (t) {
|
|
s = !0, i = t
|
|
} finally {
|
|
try {
|
|
a || null == n.return || n.return()
|
|
} finally {
|
|
if (s) throw i
|
|
}
|
|
}
|
|
return r
|
|
}(t, e) || _unsupportedIterableToArray(t, e) || function _nonIterableRest() {
|
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
|
|
}()
|
|
}
|
|
|
|
function _unsupportedIterableToArray(t, e) {
|
|
if (t) {
|
|
if ("string" == typeof t) return _arrayLikeToArray(t, e);
|
|
var n = Object.prototype.toString.call(t).slice(8, -1);
|
|
return "Object" === n && t.constructor && (n = t.constructor.name), "Map" === n || "Set" === n ? Array.from(t) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? _arrayLikeToArray(t, e) : void 0
|
|
}
|
|
}
|
|
|
|
function _arrayLikeToArray(t, e) {
|
|
(null == e || e > t.length) && (e = t.length);
|
|
for (var n = 0, o = new Array(e); n < e; n++) o[n] = t[n];
|
|
return o
|
|
}
|
|
|
|
function sliderm_defineProperties(t, e) {
|
|
for (var n = 0; n < e.length; n++) {
|
|
var o = e[n];
|
|
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o)
|
|
}
|
|
}
|
|
|
|
function _classPrivateMethodInitSpec(t, e) {
|
|
!function _checkPrivateRedeclaration(t, e) {
|
|
if (e.has(t)) throw new TypeError("Cannot initialize the same private elements twice on an object")
|
|
}(t, e), e.add(t)
|
|
}
|
|
|
|
function _classPrivateMethodGet(t, e, n) {
|
|
if (!e.has(t)) throw new TypeError("attempted to get private field on non-instance");
|
|
return n
|
|
}
|
|
|
|
var g = new WeakSet, y = new WeakSet, _ = new WeakSet, b = new WeakSet, P = new WeakSet, w = function () {
|
|
function Sliderm(t, n) {
|
|
!function sliderm_classCallCheck(t, e) {
|
|
if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function")
|
|
}(this, Sliderm), _classPrivateMethodInitSpec(this, P), _classPrivateMethodInitSpec(this, b), _classPrivateMethodInitSpec(this, _), _classPrivateMethodInitSpec(this, y), _classPrivateMethodInitSpec(this, g);
|
|
var o = getDom(t);
|
|
o ? (this.options = Object.assign(v, n), this.event = new f, this.page = new m(this), this.root = o, this.initialized = !1, this.domEvents = [], this.itemCount = 0, this.position = 1, this.modules = {}, this.slider = findDom(this.root, ".".concat(e)), this.items = [], _classPrivateMethodGet(this, g, _initialize2).call(this)) : error('The DOM "'.concat(t, '" is invalid.'))
|
|
}
|
|
|
|
return function sliderm_createClass(t, e, n) {
|
|
return e && sliderm_defineProperties(t.prototype, e), n && sliderm_defineProperties(t, n), Object.defineProperty(t, "prototype", {writable: !1}), t
|
|
}(Sliderm, [{
|
|
key: "adaptEvent", value: function adaptEvent(t) {
|
|
var e = new h(t);
|
|
return this.domEvents.push(e), e
|
|
}
|
|
}, {
|
|
key: "getPage", value: function getPage() {
|
|
return this.page
|
|
}
|
|
}, {
|
|
key: "getRoot", value: function getRoot() {
|
|
return this.root
|
|
}
|
|
}, {
|
|
key: "getItemCount", value: function getItemCount() {
|
|
return this.itemCount
|
|
}
|
|
}, {
|
|
key: "getGroupCount", value: function getGroupCount() {
|
|
return this.groupCount
|
|
}
|
|
}, {
|
|
key: "getItems", value: function getItems() {
|
|
return this.items
|
|
}
|
|
}, {
|
|
key: "getPosition", value: function getPosition() {
|
|
return this.position
|
|
}
|
|
}, {
|
|
key: "updatePosition", value: function updatePosition(t) {
|
|
this.position = t
|
|
}
|
|
}, {
|
|
key: "updateCurrentItems", value: function updateCurrentItems() {
|
|
return !this.initialized && (_classPrivateMethodGet(this, _, _updateItems2).call(this), _classPrivateMethodGet(this, b, _updateGroupCount2).call(this), !0)
|
|
}
|
|
}, {
|
|
key: "getOption", value: function getOption(t) {
|
|
var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : null,
|
|
n = void 0 !== this.options[t] ? this.options[t] : e;
|
|
if (t.includes(".")) try {
|
|
var o = t.split("."), i = _slicedToArray(o, 2), r = i[0], a = i[1];
|
|
return this.options["_".concat(r)][a]
|
|
} catch (t) {
|
|
return e
|
|
}
|
|
return n
|
|
}
|
|
}, {
|
|
key: "updateOption", value: function updateOption(t, e) {
|
|
if (t.includes(".")) try {
|
|
var n = _slicedToArray(t.split("."), 2), o = n[0], i = n[1];
|
|
this.options["_".concat(o)][i] = e
|
|
} catch (t) {
|
|
} else this.options[t] = e
|
|
}
|
|
}, {
|
|
key: "slideTo", value: function slideTo(t) {
|
|
this.go("slide", t)
|
|
}
|
|
}, {
|
|
key: "go", value: function go(t) {
|
|
var e;
|
|
if (void 0 !== this.modules[t]) {
|
|
for (var n = arguments.length, o = new Array(n > 1 ? n - 1 : 0), i = 1; i < n; i++) o[i - 1] = arguments[i];
|
|
(e = this.modules)[t].apply(e, [this, this.slider].concat(o))
|
|
} else error("Invalid module name: ".concat(t))
|
|
}
|
|
}, {
|
|
key: "on", value: function on(t, e) {
|
|
this.event.on(t, e)
|
|
}
|
|
}, {
|
|
key: "off", value: function off(t, e) {
|
|
this.event.off(t, e)
|
|
}
|
|
}, {
|
|
key: "emit", value: function emit(t) {
|
|
for (var e, n = arguments.length, o = new Array(n > 1 ? n - 1 : 0), i = 1; i < n; i++) o[i - 1] = arguments[i];
|
|
var r = [this].concat(o);
|
|
(e = this.event).emit.apply(e, [t].concat(_toConsumableArray(r)))
|
|
}
|
|
}, {
|
|
key: "destory", value: function destory() {
|
|
this.event.emit("destory"), this.event.destory(), this.domEvents.forEach((function (t) {
|
|
t.destory()
|
|
}))
|
|
}
|
|
}]), Sliderm
|
|
}();
|
|
|
|
function _initialize2() {
|
|
var t = this;
|
|
this.emit("initialize"), _classPrivateMethodGet(this, _, _updateItems2).call(this), _classPrivateMethodGet(this, b, _updateGroupCount2).call(this), _classPrivateMethodGet(this, P, _beforeMountExtensions2).call(this), _classPrivateMethodGet(this, y, _mountExtensions2).call(this), this.go("init"), this.go("breakpoint"), this.go("loop"), this.go("align"), this.go("touch"), this.go("preview"), this.go("autoplay"), this.items.forEach((function (e, n) {
|
|
t.go("columns", e), t.go("spacing", e), t.go("grouping", e, n), t.go("clone", e, n)
|
|
})), this.slideTo(1), this.initialized = !0, this.emit("initialized")
|
|
}
|
|
|
|
function _mountExtensions2() {
|
|
for (var t = 0; t < p.length; t += 1) "function" == typeof p[t] && (this.modules[p[t].name] = p[t]);
|
|
for (var e = 0; e < d.length; e += 1) "function" == typeof d[e] && this.getOption(d[e].name) && d[e](this)
|
|
}
|
|
|
|
function _updateItems2() {
|
|
this.items = Array.from(findDom(this.root, ".".concat(e)).children), this.itemCount = this.items.length
|
|
}
|
|
|
|
function _updateGroupCount2() {
|
|
var t = this.getOption("columns");
|
|
this.groupCount = Math.ceil(this.itemCount / t)
|
|
}
|
|
|
|
function _beforeMountExtensions2() {
|
|
for (var t = 0; t < this.options.extensions.length; t += 1) {
|
|
var e = this.options.extensions[t].name;
|
|
if ("" !== e) {
|
|
var n = this.options.extensions[t];
|
|
void 0 === this.options[e] ? p.push(n) : d.push(n)
|
|
}
|
|
}
|
|
}
|
|
|
|
window.Sliderm = w
|
|
})()
|
|
})(); |