zwave-js-ui
Version:
Z-Wave Control Panel and MQTT Gateway
2 lines (1 loc) • 1.71 kB
JavaScript
import{_ as R,c as M,z as P,b1 as S,U as Y,n as H}from"./index-B8xHYEBg.js";const L="horizontal",u="vertical",W={name:"multipane",props:{layout:{type:String,default:u}},data(){return{isResizing:!1}},computed:{classnames(){return["multipane","layout-"+this.layout.slice(0,1),this.isResizing?"is-resizing":""]},cursor(){return this.isResizing?this.layout==u?"col-resize":"row-resize":""},userSelect(){return this.isResizing?"none":""}},methods:{getPageXY(i){return i.touches?.[0]||i},onMouseDown(i){const t=i.target;if(t.className&&t.className.match("multipane-resizer")){let{$el:z,layout:n}=this;const{pageX:f,pageY:s}=this.getPageXY(i);let e=t.previousElementSibling,{offsetWidth:w,offsetHeight:y}=e,v=!!(e.style.width+"").match("%");const{addEventListener:c,removeEventListener:h}=window,o=(p,d=0)=>{if(n==u){let r=z.clientWidth,l=p+d;return e.style.width=v?l/r*100+"%":l+"px"}if(n==L){let r=z.clientHeight,l=p+d;return e.style.height=v?l/r*100+"%":l+"px"}};this.isResizing=!0;let a=o();this.$emit("paneResizeStart",e,t,a);const m=p=>{const{pageX:d,pageY:r}=this.getPageXY(p);a=n==u?o(w,d-f):o(y,r-s),this.$emit("paneResize",e,t,a)},g=()=>{a=n==u?o(e.clientWidth):o(e.clientHeight),this.isResizing=!1,h("mousemove",m),h("mouseup",g),h("touchmove",m),h("touchend",g),this.$emit("paneResizeStop",e,t,a)};c("mousemove",m),c("mouseup",g),c("touchmove",m),c("touchend",g)}}}};function X(i,t,z,n,f,s){return P(),M("div",{class:H(s.classnames),style:Y({cursor:s.cursor,userSelect:s.userSelect}),onMousedown:t[0]||(t[0]=(...e)=>s.onMouseDown&&s.onMouseDown(...e)),onTouchstart:t[1]||(t[1]=(...e)=>s.onMouseDown&&s.onMouseDown(...e))},[S(i.$slots,"default")],38)}const D=R(W,[["render",X]]);export{D as default};