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