UNPKG

@layui/layui-vue

Version:

a component library for Vue 3 base on layui-vue

26 lines (25 loc) 1.06 kB
import { useThrottleFn as L } from "@vueuse/core"; let r = !1, c = null, o = null, s = null, u = null, m = 0, d = 0, i = 0; const f = L((l) => { if (!r) return; const t = l.clientX - m, n = d + t; if (n < 0) return !1; c.width = n + "px", o && (o.style.width = i + t + "px"), s && (s.style.width = i + t + "px"), u && (u.style.width = i + t + "px"); }, 20), v = () => { m = 0, d = 0, i = 0, c = null, o = null, s = null, r = !1, document.removeEventListener("mousemove", f), document.removeEventListener("mouseup", v); }, N = (l, t, n, w, x) => { var a, p; document.addEventListener("mousemove", f), document.addEventListener("mouseup", v), o = n, s = w, u = x, c = t, m = l.clientX; const h = []; if (n && ((p = (a = n.firstChild) == null ? void 0 : a.childNodes) == null || p.forEach((e) => { e.clientWidth && h.push(e.clientWidth); })), i = h.reduce((e, E) => e + E, 0), r = !0, d = l.target.parentNode.offsetWidth, t.width) { const e = t.width.match(/^(\d+)px$/i); e && (d = +e[1]); } }; export { N as startResize };