forked from BabylonJS/Babylon.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplit.js
1 lines (1 loc) · 5.19 KB
/
split.js
1
"use strict"; (function () { var t = this, e = t.attachEvent && !t[r], i = t.document, r = "addEventListener", s = "removeEventListener", n = "getBoundingClientRect", o = function () { for (var t, e = ["", "-webkit-", "-moz-", "-o-"], r = 0; r < e.length; r++)if (t = i.createElement("div"), t.style.cssText = "width:" + e[r] + "calc(9px)", t.style.length) return e[r] + "calc" }(), a = function (t) { return "string" == typeof t || t instanceof String ? i.querySelector(t) : t }, l = function (l, c) { var u, g, h, p, d, z, S, f, v = []; c = void 0 !== c ? c : {}, void 0 === c.gutterSize && (c.gutterSize = 10), void 0 === c.minSize && (c.minSize = 100), void 0 === c.snapOffset && (c.snapOffset = 30), void 0 === c.direction && (c.direction = "horizontal"), "horizontal" == c.direction ? (u = "width", h = "clientWidth", p = "clientX", d = "left", z = "gutter gutter-horizontal", S = "paddingLeft", f = "paddingRight", c.cursor || (c.cursor = "ew-resize")) : "vertical" == c.direction && (u = "height", h = "clientHeight", p = "clientY", d = "top", z = "gutter gutter-vertical", S = "paddingTop", f = "paddingBottom", c.cursor || (c.cursor = "ns-resize")), c.blockDrag && (z += " blocked"); var y = function (e) { if (!c.blockDrag) { var i = this, s = i.a, n = i.b; !i.dragging && c.onDragStart && c.onDragStart(), e.preventDefault(), i.dragging = !0, i.move = b.bind(i), i.stop = m.bind(i), t[r]("mouseup", i.stop), t[r]("touchend", i.stop), t[r]("touchcancel", i.stop), i.parent[r]("mousemove", i.move), i.parent[r]("touchmove", i.move), s[r]("selectstart", E), s[r]("dragstart", E), n[r]("selectstart", E), n[r]("dragstart", E), s.style.userSelect = "none", s.style.webkitUserSelect = "none", s.style.MozUserSelect = "none", s.style.pointerEvents = "none", n.style.userSelect = "none", n.style.webkitUserSelect = "none", n.style.MozUserSelect = "none", n.style.pointerEvents = "none", i.gutter.style.cursor = c.cursor, i.parent.style.cursor = c.cursor, G.call(i) } }, m = function () { if (!c.blockDrag) { var e = this, i = e.a, r = e.b; e.dragging && c.onDragEnd && c.onDragEnd(), e.dragging = !1, t[s]("mouseup", e.stop), t[s]("touchend", e.stop), t[s]("touchcancel", e.stop), e.parent[s]("mousemove", e.move), e.parent[s]("touchmove", e.move), delete e.stop, delete e.move, i[s]("selectstart", E), i[s]("dragstart", E), r[s]("selectstart", E), r[s]("dragstart", E), i.style.userSelect = "", i.style.webkitUserSelect = "", i.style.MozUserSelect = "", i.style.pointerEvents = "", r.style.userSelect = "", r.style.webkitUserSelect = "", r.style.MozUserSelect = "", r.style.pointerEvents = "", e.gutter.style.cursor = "", e.parent.style.cursor = "" } }, b = function (t) { var e; this.dragging && (e = "touches" in t ? t.touches[0][p] - this.start : t[p] - this.start, e > this.aMin + c.snapOffset + this.aGutterSize ? e < this.size - (this.bMin + c.snapOffset + this.bGutterSize) || (e = this.size - (this.bMin + this.bGutterSize)) : e = this.aMin + this.aGutterSize, w.call(this, e), c.onDrag && c.onDrag()) }, G = function () { var e = t.getComputedStyle(this.parent), i = this.parent[h] - parseFloat(e[S]) - parseFloat(e[f]); this.size = this.a[n]()[u] + this.b[n]()[u] + this.aGutterSize + this.bGutterSize, this.percentage = Math.min(this.size / i * 100, 100), this.start = this.a[n]()[d] }, w = function (t) { this.a.style[u] = o + "(" + t / this.size * this.percentage + "% - " + this.aGutterSize + "px)", this.b.style[u] = o + "(" + (this.percentage - t / this.size * this.percentage) + "% - " + this.bGutterSize + "px)" }, x = function (t, i, r) { "string" == typeof i || i instanceof String || (i = e ? c.sizes[g] + "%" : o + "(" + i + "% - " + r + "px)"), t.style[u] = i }, E = function () { return !1 }, M = a(l[0]).parentNode; if (!c.sizes) { var D = 100 / l.length; for (c.sizes = [], g = 0; g < l.length; g++)c.sizes.push(D) } if (!Array.isArray(c.minSize)) { var k = []; for (g = 0; g < l.length; g++)k.push(c.minSize); c.minSize = k } for (g = 0; g < l.length; g++) { var U, L = a(l[g]), O = 1 == g, B = g == l.length - 1, C = c.sizes[g], F = c.gutterSize; if (g > 0 && (U = { a: a(l[g - 1]), b: L, aMin: c.minSize[g - 1], bMin: c.minSize[g], dragging: !1, parent: M, isFirst: O, isLast: B, direction: c.direction }, U.aGutterSize = c.gutterSize, U.bGutterSize = c.gutterSize, O && (U.aGutterSize = c.gutterSize / 2), B && (U.bGutterSize = c.gutterSize / 2)), !e) { if (g > 0) { var A = i.createElement("div"); A.className = z, A.style[u] = c.gutterSize + "px", A[r]("mousedown", y.bind(U)), A[r]("touchstart", y.bind(U)), M.insertBefore(A, L), U.gutter = A } (0 === g || g == l.length - 1) && (F = c.gutterSize / 2) } x(L, C, F), g > 0 && v.push(U) } return { setSizes: function (t) { for (var e = 0; e < t.length; e++)if (e > 0) { var i = v[e - 1]; x(i.a, t[e - 1], i.aGutterSize), x(i.b, t[e], i.bGutterSize) } }, collapse: function (t) { var e; t === v.length ? (e = v[t - 1], G.call(e), w.call(e, e.size - e.bGutterSize)) : (e = v[t], G.call(e), w.call(e, e.aGutterSize)) }, destroy: function () { for (var t = 0; t < v.length; t++)v[t].parent.removeChild(v[t].gutter), v[t].a.style[u] = "", v[t].b.style[u] = "" } } }; "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = l), exports.Split = l) : t.Split = l }).call(window);