提交 | 用户 | 时间
|
1ac2bc
|
1 |
/*! Split.js - v1.5.9 */ |
懒 |
2 |
!function (e, t) { |
|
3 |
if ("object" == typeof exports && "undefined" != typeof module) { |
|
4 |
module.exports = t() |
|
5 |
} else if ("function" == typeof define && define.amd) { |
|
6 |
define(t) |
|
7 |
} else if (window.layui && layui.define) { // layui加载 |
|
8 |
layui.define(function (exports) { |
|
9 |
layui.link(layui.cache.base + 'Split/Split.css'); |
|
10 |
exports('Split', t()); |
|
11 |
}); |
|
12 |
} else { |
|
13 |
e.Split = t() |
|
14 |
} |
|
15 |
/* |
|
16 |
"object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : e.Split = t() |
|
17 |
*/ |
|
18 |
}(this, function () { |
|
19 |
"use strict"; |
|
20 |
var B = window, L = B.document, T = "addEventListener", N = "removeEventListener", R = "getBoundingClientRect", |
|
21 |
q = "horizontal", H = function () { |
|
22 |
return !1 |
|
23 |
}, I = B.attachEvent && !B[T], i = ["", "-webkit-", "-moz-", "-o-"].filter(function (e) { |
|
24 |
var t = L.createElement("div"); |
|
25 |
return t.style.cssText = "width:" + e + "calc(9px)", !!t.style.length |
|
26 |
}).shift() + "calc", s = function (e) { |
|
27 |
return "string" == typeof e || e instanceof String |
|
28 |
}, W = function (e) { |
|
29 |
if (s(e)) { |
|
30 |
var t = L.querySelector(e); |
|
31 |
if (!t) throw new Error("Selector " + e + " did not match a DOM element"); |
|
32 |
return t |
|
33 |
} |
|
34 |
return e |
|
35 |
}, X = function (e, t, n) { |
|
36 |
var r = e[t]; |
|
37 |
return void 0 !== r ? r : n |
|
38 |
}, Y = function (e, t, n, r) { |
|
39 |
if (t) { |
|
40 |
if ("end" === r) return 0; |
|
41 |
if ("center" === r) return e / 2 |
|
42 |
} else if (n) { |
|
43 |
if ("start" === r) return 0; |
|
44 |
if ("center" === r) return e / 2 |
|
45 |
} |
|
46 |
return e |
|
47 |
}, G = function (e, t) { |
|
48 |
var n = L.createElement("div"); |
|
49 |
return n.className = "gutter gutter-" + t, n |
|
50 |
}, J = function (e, t, n) { |
|
51 |
var r = {}; |
|
52 |
return s(t) ? r[e] = t : r[e] = I ? t + "%" : i + "(" + t + "% - " + n + "px)", r |
|
53 |
}, K = function (e, t) { |
|
54 |
var n; |
|
55 |
return (n = {})[e] = t + "px", n |
|
56 |
}; |
|
57 |
return function (e, i) { |
|
58 |
void 0 === i && (i = {}); |
|
59 |
var u, t, s, o, r, a, l = e; |
|
60 |
Array.from && (l = Array.from(l)); |
|
61 |
var c = W(l[0]).parentNode, f = getComputedStyle ? getComputedStyle(c).flexDirection : null, |
|
62 |
m = X(i, "sizes") || l.map(function () { |
|
63 |
return 100 / l.length |
|
64 |
}), n = X(i, "minSize", 100), h = Array.isArray(n) ? n : l.map(function () { |
|
65 |
return n |
|
66 |
}), d = X(i, "expandToMin", !1), g = X(i, "gutterSize", 5), v = X(i, "gutterAlign", "center"), |
|
67 |
p = X(i, "snapOffset", 30), y = X(i, "dragInterval", 1), z = X(i, "direction", q), |
|
68 |
S = X(i, "cursor", z === q ? "col-resize" : "row-resize"), b = X(i, "gutter", G), |
|
69 |
_ = X(i, "elementStyle", J), E = X(i, "gutterStyle", K); |
|
70 |
|
|
71 |
function w(t, e, n, r) { |
|
72 |
var i = _(u, e, n, r); |
|
73 |
Object.keys(i).forEach(function (e) { |
|
74 |
t.style[e] = i[e] |
|
75 |
}) |
|
76 |
} |
|
77 |
|
|
78 |
function k() { |
|
79 |
return a.map(function (e) { |
|
80 |
return e.size |
|
81 |
}) |
|
82 |
} |
|
83 |
|
|
84 |
function x(e) { |
|
85 |
return "touches" in e ? e.touches[0][t] : e[t] |
|
86 |
} |
|
87 |
|
|
88 |
function M(e) { |
|
89 |
var t = a[this.a], n = a[this.b], r = t.size + n.size; |
|
90 |
t.size = e / this.size * r, n.size = r - e / this.size * r, w(t.element, t.size, this._b, t.i), w(n.element, n.size, this._c, n.i) |
|
91 |
} |
|
92 |
|
|
93 |
function U() { |
|
94 |
var e = a[this.a].element, t = a[this.b].element, n = e[R](), r = t[R](); |
|
95 |
this.size = n[u] + r[u] + this._b + this._c, this.start = n[s], this.end = n[o] |
|
96 |
} |
|
97 |
|
|
98 |
function O(s) { |
|
99 |
var o = function (e) { |
|
100 |
if (!getComputedStyle) return null; |
|
101 |
var t = getComputedStyle(e), n = e[r]; |
|
102 |
return 0 === n ? null : n -= z === q ? parseFloat(t.paddingLeft) + parseFloat(t.paddingRight) : parseFloat(t.paddingTop) + parseFloat(t.paddingBottom) |
|
103 |
}(c); |
|
104 |
if (null === o) return s; |
|
105 |
var a = 0, u = [], e = s.map(function (e, t) { |
|
106 |
var n = o * e / 100, r = Y(g, 0 === t, t === s.length - 1, v), i = h[t] + r; |
|
107 |
return n < i ? (a += i - n, u.push(0), i) : (u.push(n - i), n) |
|
108 |
}); |
|
109 |
return 0 === a ? s : e.map(function (e, t) { |
|
110 |
var n = e; |
|
111 |
if (0 < a && 0 < u[t] - a) { |
|
112 |
var r = Math.min(a, u[t] - a); |
|
113 |
a -= r, n = e - r |
|
114 |
} |
|
115 |
return n / o * 100 |
|
116 |
}) |
|
117 |
} |
|
118 |
|
|
119 |
function C(e) { |
|
120 |
if (!("button" in e && 0 !== e.button)) { |
|
121 |
var t = this, n = a[t.a].element, r = a[t.b].element; |
|
122 |
t.dragging || X(i, "onDragStart", H)(k()), e.preventDefault(), t.dragging = !0, t.move = function (e) { |
|
123 |
var t, n = a[this.a], r = a[this.b]; |
|
124 |
this.dragging && (t = x(e) - this.start + (this._b - this.dragOffset), 1 < y && (t = Math.round(t / y) * y), t <= n.minSize + p + this._b ? t = n.minSize + this._b : t >= this.size - (r.minSize + p + this._c) && (t = this.size - (r.minSize + this._c)), M.call(this, t), X(i, "onDrag", H)()) |
|
125 |
}.bind(t), t.stop = function () { |
|
126 |
var e = this, t = a[e.a].element, n = a[e.b].element; |
|
127 |
e.dragging && X(i, "onDragEnd", H)(k()), e.dragging = !1, B[N]("mouseup", e.stop), B[N]("touchend", e.stop), B[N]("touchcancel", e.stop), B[N]("mousemove", e.move), B[N]("touchmove", e.move), e.stop = null, e.move = null, t[N]("selectstart", H), t[N]("dragstart", H), n[N]("selectstart", H), n[N]("dragstart", H), t.style.userSelect = "", t.style.webkitUserSelect = "", t.style.MozUserSelect = "", t.style.pointerEvents = "", n.style.userSelect = "", n.style.webkitUserSelect = "", n.style.MozUserSelect = "", n.style.pointerEvents = "", e.gutter.style.cursor = "", e.parent.style.cursor = "", L.body.style.cursor = "" |
|
128 |
}.bind(t), B[T]("mouseup", t.stop), B[T]("touchend", t.stop), B[T]("touchcancel", t.stop), B[T]("mousemove", t.move), B[T]("touchmove", t.move), n[T]("selectstart", H), n[T]("dragstart", H), r[T]("selectstart", H), r[T]("dragstart", H), n.style.userSelect = "none", n.style.webkitUserSelect = "none", n.style.MozUserSelect = "none", n.style.pointerEvents = "none", r.style.userSelect = "none", r.style.webkitUserSelect = "none", r.style.MozUserSelect = "none", r.style.pointerEvents = "none", t.gutter.style.cursor = S, t.parent.style.cursor = S, L.body.style.cursor = S, U.call(t), t.dragOffset = x(e) - t.end |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
132 |
z === q ? (u = "width", t = "clientX", s = "left", o = "right", r = "clientWidth") : "vertical" === z && (u = "height", t = "clientY", s = "top", o = "bottom", r = "clientHeight"), m = O(m); |
|
133 |
var D = []; |
|
134 |
|
|
135 |
function A(e) { |
|
136 |
var t = e.i === D.length, n = t ? D[e.i - 1] : D[e.i]; |
|
137 |
U.call(n); |
|
138 |
var r = t ? n.size - e.minSize - n._c : e.minSize + n._b; |
|
139 |
M.call(n, r) |
|
140 |
} |
|
141 |
|
|
142 |
function j(e) { |
|
143 |
var s = O(e); |
|
144 |
s.forEach(function (e, t) { |
|
145 |
if (0 < t) { |
|
146 |
var n = D[t - 1], r = a[n.a], i = a[n.b]; |
|
147 |
r.size = s[t - 1], i.size = e, w(r.element, r.size, n._b), w(i.element, i.size, n._c) |
|
148 |
} |
|
149 |
}) |
|
150 |
} |
|
151 |
|
|
152 |
function F(n, r) { |
|
153 |
D.forEach(function (t) { |
|
154 |
if (!0 !== r ? t.parent.removeChild(t.gutter) : (t.gutter[N]("mousedown", t._a), t.gutter[N]("touchstart", t._a)), !0 !== n) { |
|
155 |
var e = _(u, t.a.size, t._b); |
|
156 |
Object.keys(e).forEach(function (e) { |
|
157 |
a[t.a].element.style[e] = "", a[t.b].element.style[e] = "" |
|
158 |
}) |
|
159 |
} |
|
160 |
}) |
|
161 |
} |
|
162 |
|
|
163 |
return (a = l.map(function (e, t) { |
|
164 |
var n, r, i, s = {element: W(e), size: m[t], minSize: h[t], i: t}; |
|
165 |
if (0 < t && ((n = { |
|
166 |
a: t - 1, |
|
167 |
b: t, |
|
168 |
dragging: !1, |
|
169 |
direction: z, |
|
170 |
parent: c |
|
171 |
})._b = Y(g, t - 1 == 0, !1, v), n._c = Y(g, !1, t === l.length - 1, v), "row-reverse" === f || "column-reverse" === f)) { |
|
172 |
var o = n.a; |
|
173 |
n.a = n.b, n.b = o |
|
174 |
} |
|
175 |
if (!I && 0 < t) { |
|
176 |
var a = b(t, z, s.element); |
|
177 |
r = a, i = E(u, g, t), Object.keys(i).forEach(function (e) { |
|
178 |
r.style[e] = i[e] |
|
179 |
}), n._a = C.bind(n), a[T]("mousedown", n._a), a[T]("touchstart", n._a), c.insertBefore(a, s.element), n.gutter = a |
|
180 |
} |
|
181 |
return w(s.element, s.size, Y(g, 0 === t, t === l.length - 1, v)), 0 < t && D.push(n), s |
|
182 |
})).forEach(function (e) { |
|
183 |
var t = e.element[R]()[u]; |
|
184 |
t < e.minSize && (d ? A(e) : e.minSize = t) |
|
185 |
}), I ? {setSizes: j, destroy: F} : { |
|
186 |
setSizes: j, getSizes: k, collapse: function (e) { |
|
187 |
A(a[e]) |
|
188 |
}, destroy: F, parent: c, pairs: D |
|
189 |
} |
|
190 |
} |
|
191 |
}); |
|
192 |
//# sourceMappingURL=split.min.js.map |