(function(q, z) { "function" === typeof define && define.amd ? define([], z(q)) : "object" === typeof exports ? module.exports = z(q) : q.floatingCarousel = z(q) })("undefined" !== typeof global ? global : this.window || this.global, function(q) { var z = !!document.querySelector && !!q.addEventListener, H = window.jQuery, u, W = { autoScroll: !1, //自动滚动 autoScrollDirection: "left", autoScrollSpeed: 1E4, initClass: "floatingCarouselContainer", intervalRate: 16, looped: !0, scrollerAlignment: "horizontal", scrollerOffset: 0, scrollSpeed: "medium", beforeCreateFunction: null, afterCreateFunction: null, enableTouchEvents: !0, touchOverflowHidden: !0, reverseOnTouch: !0 }, r = function(c, l, f) { if ("[object Object]" === Object.prototype.toString.call(c)) for (var a in c) Object.prototype.hasOwnProperty.call(c, a) && l.call(f, c[a], a, c); else { a = 0; for (var X = c.length; a < X; a++) l.call(f, c[a], a, c) } }, Y = function(c, l) { var f = {}; r(c, function(a, l) { f[l] = c[l] }); r(l, function(a, c) { f[c] = l[c] }); return f }, A = function(c, l) { if (c.length) r(c, function(a) { for (var c in l) a.style[c] = l[c] }); else for (var f in l) c.style[f] = l[f]; return c }, M = function(c, l) { var f = Element.prototype; return (f.matches || f.webkitMatchesSelector || f.mozMatchesSelector || f.msMatchesSelector || function(a) { return -1 !== [].indexOf.call(document.querySelectorAll(a), this) }).call(c, l) }, D = function(c, l) { return Array.prototype.filter.call(c.children, function(c) { return M(c, l) }) }, N = function(c) { console.log('节点444'); c = c.getBoundingClientRect(); var l = window.pageYOffset || document.documentElement.scrollTop, f = window.pageXOffset || document.documentElement.scrollLeft; return { top: parseInt(c.top) + l, left: parseInt(c.left) + f } }, I = function(c, l) { var f = {}, a = c || []; "string" == typeof a && (a = document.querySelectorAll(a)); if (1 < a.length) { var q = []; r(a, function(b) { 1 === b.nodeType && q.push(I(b, l)) }); return q } a = a[0] || a; var k = 0, y = !1, h = 0, J = 0, E = 0, v, g, p, F, B, n, e, d, w, C, x, m, t, b, G = function(a, d) { return "left" == a ? y && b.reverseOnTouch ? d > t : d < t : y && b.reverseOnTouch ? d < t : d > t }, K = function() { 0 != b.looped && (p && (clearInterval(p), p = 0), d = d ? d : "vertical" != b.scrollerAlignment.toLowerCase() ? parseInt(e[0].style.left) : parseInt(e[0].style.top), b.autoScrollSpeed = 1E3 > b.autoScrollSpeed ? 1E3 : b.autoScrollSpeed, b.autoScrollSpeed / v < n ? m = Math.round(n / (b.autoScrollSpeed / v)) : (m = 1, v = Math.round(b.autoScrollSpeed / n)), p = setInterval(function() { switch (b.autoScrollDirection.toLowerCase()) { case "right": case "down": d + m > h ? (d = 0, k = 0 == k ? 1 : 0) : d += m; break; default: d - m < 0 - (h - n) ? (d = n, k = 0 == k ? 1 : 0) : d -= m } "vertical" != b.scrollerAlignment.toLowerCase() ? (e[k].style.left = d + "px", e[0 == k ? 1 : 0].style.left = d - h + "px") : (e[k].style.top = d + "px", e[0 == k ? 1 : 0].style.top = d - h + "px") }, v)) }, O = function() { clearInterval(p); //鼠标移入暂停 // p && // (clearInterval(p), p = 0); // t = "vertical" != b.scrollerAlignment.toLowerCase() ? Math.round(N(g).left + g.offsetWidth / 2) : Math.round(N(g).top + g.offsetHeight / 2); // d = d ? d : "vertical" != b.scrollerAlignment.toLowerCase() ? parseInt(e[0].style.left) : parseInt(e[0].style.top); // u = setInterval(function() { // try { var a = "vertical" != b.scrollerAlignment.toLowerCase() ? B.x : B.y } catch (Z) { return } // var c = n / 2; // var f = a < t ? t - a : a - t; // m = f < Math.ceil(c / 100 * 30) ? 1 : f < Math.ceil(c / 100 * 50) ? 2 * w : f < Math.ceil(c / 100 * 70) ? 3 * w : f < Math.ceil(c / 100 * 90) ? 4 * w : 6 * w; // G("left", a) ? // 0 < d + m && 0 == b.looped ? d = 0 : d + m > h ? (d = 0, k = 0 == k ? 1 : 0) : d += m : G("right", a) && (d - m < 0 - (h - n) ? 0 == b.looped ? d = 0 - (h - n) : (d = n, k = 0 == k ? 1 : 0) : d -= m); // "vertical" != b.scrollerAlignment.toLowerCase() ? (e[k].style.left = d + "px", e[0 == k ? 1 : 0].style.left = d - h + "px") : (e[k].style.top = d + "px", e[0 == k ? 1 : 0].style.top = d - h + "px") // }, v) }, L = function(a) { if (u && (clearInterval(u), u = 0, a && 0 != b.looped && 1 != b.autoScroll && 1 < m)) { a = 0; for (var c = m; 1 < c; c--) a += c; var f = "vertical" != b.scrollerAlignment.toLowerCase() ? B.x : B.y; G("left", f) ? d + a > h && (d -= h, k = 0 == k ? 1 : 0) : d - a < 0 - (h - n) && (d += h, k = 0 == k ? 1 : 0); var g = setInterval(function() { 1 < m ? (d = G("left", f) ? d + m : d - m, "vertical" != b.scrollerAlignment.toLowerCase() ? (e[k].style.left = d + "px", e[0 == k ? 1 : 0].style.left = d - h + "px") : (e[k].style.top = d + "px", e[0 == k ? 1 : 0].style.top = d - h + "px"), m--) : clearInterval(g) }, v) } }, P = function(a) { var b = { x: 0, y: 0 }; if (a.changedTouches) a = a.changedTouches[0], b.x = a.pageX, b.y = a.pageY; else if (a.pageX || a.pageY) b.x = a.pageX, b.y = a.pageY; else { var c = document.documentElement, d = document.body; b.x = a.clientX + ((c.scrollLeft || d.scrollLeft) - (c.clientLeft || 0)); b.y = a.clientY + ((c.scrollTop || d.scrollTop) - (c.clientTop || 0)) } B = b }, Q = function() { y = !0; b.touchOverflowHidden && (document.body.style.overflow = "hidden"); O() }, R = function() { b.touchOverflowHidden && (document.body.style.overflow = ""); L(!0); 1 == b.autoScroll && K() }, S = function(a) { P(a) }, T = function() { y || O() }, U = function() { y || (L(!0), 1 == b.autoScroll && K()) }, V = function(a) { y || P(a) }; f.destroy = function() { b && (f.pause(), 1 < a.children.length && e[1].parentNode.removeChild(e[1]), r(e[0].children, function(a) { a.removeAttribute("style") }), M(e[0], "div") ? a.innerHTML = e[0].innerHTML : e[0].removeAttribute("style"), a.removeAttribute("style"), a.classList.remove(b.initClass), d = b = null, h = 0) }; f.update = function(a) { f.destroy(); f.init(a) }; f.play = function() { F || (b.enableTouchEvents && (a.addEventListener("touchstart", Q), a.addEventListener("touchend", R), a.addEventListener("touchmove", S)), a.addEventListener("mouseenter", T), a.addEventListener("mouseleave", U), a.addEventListener("mousemove", V), !0 === b.autoScroll && K(), F = !0) }; f.pause = function() { F && (L(), p && (clearInterval(p), p = 0), u && (clearInterval(u), u = 0), b.enableTouchEvents && (a.removeEventListener("touchstart", Q), a.removeEventListener("touchend", R), a.removeEventListener("touchmove", S)), a.removeEventListener("mouseenter", T), a.removeEventListener("mouseleave", U), a.removeEventListener("mousemove", V), F = !1) }; f.init = function(c) { if (1 > a.length) return !1; g = a; if (z) { b = Y(W, c || {}); null != b.beforeCreateFunction && "function" === typeof b.beforeCreateFunction && b.beforeCreateFunction.call(a); a.classList.add(b.initClass); v = b.intervalRate; g.style.paddingLeft = "0"; g.style.paddingRight = "0"; n = g.offsetWidth; switch (a.children[0].nodeName.toLowerCase()) { case "div": g.innerHTML = "