2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
|
|
import{a0 as e,a5 as t,a9 as r,m as a,T as n,aa as s,R as i,X as l,a4 as o,a8 as u,aB as c,ab as f}from"./index-d685dfc2.js";import{t as h}from"./error-c58402b8.js";import{w as d,P as v,ar as m,i as p,a8 as y,aN as g,aj as $,j as w,b1 as b,b3 as S,m as M,a3 as _,aR as D,a5 as x,l as O,t as z,F as T,aY as k,a2 as H,al as L,ap as E,ac as Y,ai as j,au as C,ax as W,k as N,b8 as A}from"./runtime-core.esm-bundler-42d2bde8.js";var B="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function R(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function P(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){if(this instanceof e){var r=[null];r.push.apply(r,arguments);var a=Function.bind.apply(t,r);return new a}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,a.get?a:{enumerable:!0,get:function(){return e[t]}})})),r}const I=Symbol("scrollbarContextKey"),F={vertical:{offset:"offsetHeight",scroll:"scrollTop",scrollSize:"scrollHeight",size:"height",key:"vertical",axis:"Y",client:"clientY",direction:"top"},horizontal:{offset:"offsetWidth",scroll:"scrollLeft",scrollSize:"scrollWidth",size:"width",key:"horizontal",axis:"X",client:"clientX",direction:"left"}},X=e({vertical:Boolean,size:String,move:Number,ratio:{type:Number,required:!0},always:Boolean});var U=s(d({__name:"thumb",props:X,setup(e){const s=e,l=v(I),o=t("scrollbar");l||h("Thumb","can not inject scrollbar context");const u=m(),c=m(),f=m({}),d=m(!1);let O=!1,z=!1,T=i?document.onselectstart:null;const k=p((()=>F[s.vertical?"vertical":"horizontal"])),H=p((()=>(({move:e,size:t,bar:r})=>({[r.size]:t,transform:`translate${r.axis}(${e}%)`}))({size:s.size,move:s.move,bar:k.value}))),L=p((()=>u.value[k.value.offset]**2/l.wrapElement[k.value.scrollSize]/s.ratio/c.value[k.value.offset])),E=e=>{var t;if(e.stopPropagation(),e.ctrlKey||[1,2].includes(e.button))return;null==(t=window.getSelection())||t.removeAllRanges(),j(e);const r=e.currentTarget;r&&(f.value[k.value.axis]=r[k.value.offset]-(e[k.value.client]-r.getBoundingClientRect()[k.value.direction]))},Y=e=>{if(!c.value||!u.value||!l.wrapElement)return;const t=100*(Math.abs(e.target.getBoundingClientRect()[k.value.direction]-e[k.value.client])-c.value[k.value.offset]/2)*L.value/u.value[k.value.offset];l.wrapElement[k.value.scroll]=t*l.wrapElement[k.value.scrollSize]/100},j=e=>{e.stopImmediatePropagation(),O=!0,document.addEventListener("mousemove",C),document.addEventListener("mouseup",W),T=document.onselectstart,document.onselectstart=()=>!1},C=e=>{if(!u.value||!c.value)return;if(!1===O)return;const t=f.value[k.value.axis];if(!t)return;const r=100*(-1*(u.value.getBoundingClientRect()[k.value.direction]-e[k.value.client])-(c.value[k.value.offset]-t))*L.value/u.value[k.value.offset];l.wrapElement[k.value.scroll]=r*l.wrapElement[k.value.scrollSize]/100},W=()=>{O=!1,f.value[k.value.axis]=0,document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",W),N(),z&&(d.value=!1)};y((()=>{N(),document.removeEventListener("mouseup",W)}));const N=()=>{document.onselectstart!==T&&(document.onselectstart=T)};return r(g(l,"scrollbarElement"),"mousemove",(()=>{z=!1,d.value=!!s.size})),r(g(l,"scrollbarElement"),"mouseleave",(()=>{z=!0,d.value=O})),(e,t)=>($(),w(n,{name:D(o).b("fade"),persisted:""},{default:b((()=>[S(M("div",{ref_key:"instance",ref:u,class:_([D(o).e("bar"),D(o).is(D(k).key)]),onMousedown:Y},[M("div",{ref_key:"thumb",ref:c,class:_(D(o).e("thumb")),style:x(D(H)),onMousedown:E},null,38)],34),[[a,e.always||d.value]])])),_:1},8,["name"]))}}),[["__file","/home/runner/work/element-plus/element-plus/packages/components/scrollbar/src/thumb.vue"]]);var J=s(d({__name:"bar",props:e({always:{type:Boolean,default:!0},width:String,height:String,ratioX:{type:Number,default:1},ratioY:{type:Numbe
|