dk-plus
Version:
2 lines (1 loc) • 1.54 kB
JavaScript
;Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("vue");const l=require("../../public/get-color/index.js");require("../../../_icon/index.js");const d=()=>{const c=(r,t,e,o)=>{o=l.getColor(o).rgbaToHex();const s=l.getColor(o).hexToRgba(t).replace(/rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d+)\)/,"$1, $2, $3"),u=()=>{t+=e,t<1&&t>0&&(r.style.setProperty("--scrollbar-thumb-color",`rgba(${s}, ${t})`),requestAnimationFrame(u))};u()},i=r=>{r.classList.remove("dk-scrollbar"),r.removeEventListener("mouseenter",()=>{}),r.removeEventListener("mouseleave",()=>{})},n=(r,t)=>{const e=s=>t.value[s],o=s=>e(s)||r.getAttribute(`${s}`)||"";return{width:o("width"),height:o("height"),barWidth:o("bar-width"),thumbRadius:o("thumb-radius"),trackColor:o("track-color"),thumbColor:o("thumb-color")}},a=(r,t)=>{r.className="dk-scrollbar";const e=n(r,t),o=l.getColor(e.thumbColor||"#c1c1c1").hexToRgba(0);e.width&&r.style.setProperty("--scrollbar-width",e.width),e.height&&r.style.setProperty("--scrollbar-height",e.height),e.trackColor&&r.style.setProperty("--scrollbar-track-color",e.trackColor),e.barWidth&&r.style.setProperty("--scrollbar-bar-width",e.barWidth),e.thumbRadius&&r.style.setProperty("--scrollbar-thumb-radius",e.thumbRadius),r.style.setProperty("--scrollbar-thumb-color",o),r.addEventListener("mouseenter",()=>c(r,0,.1,o)),r.addEventListener("mouseleave",()=>c(r,1,-.1,o))};return{mounted:(r,t)=>{t.value&&a(r,t)},updated:(r,t)=>{t.value?a(r,t):i(r)}}};exports.DirectiveScroll=d;