Files
YGChatCS/unpackage/dist/dev/mp-weixin/third/ex-drawer/ex-drawer.js
2025-06-29 23:41:37 +08:00

97 lines
2.9 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const _sfc_main = {
data() {
return {
maskShow: false,
startX: 0,
startY: 0,
moveX: 0,
moveY: 0,
startExcursion: 0,
differential: 0,
isDirection: null,
iswidth: null,
move: false
};
},
props: {
width: {
type: String,
default: ""
}
},
methods: {
containerStart(e) {
this.isDirection = null;
this.move = false;
this.startX = e.changedTouches[0].clientX;
this.startY = e.changedTouches[0].clientY;
this.startExcursion = this.differential;
},
containerMove(e) {
this.moveX = e.changedTouches[0].clientX;
this.moveY = e.changedTouches[0].clientY;
let X = Math.abs(this.moveX - this.startX);
let Y = Math.abs(this.moveY - this.startY);
let differential = this.startExcursion + this.moveX - this.startX;
differential = Math.min(common_vendor.index.upx2px(this.width), differential);
differential = Math.max(0, differential);
this.isDirection == null ? this.isDirection = Y / X > Math.sqrt(3) / 3 : ``;
if (!this.isDirection) {
this.differential = differential;
if (this.differential == 0) {
this.containerEnd();
} else {
this.maskShow = true;
}
}
},
containerEnd() {
if (this.isDirection != null) {
if (!this.isDirection) {
this.iswidth = this.differential > common_vendor.index.upx2px(this.width) * 2 / 6;
this.differential > 0 && this.differential < common_vendor.index.upx2px(this.width) ? this.move = true : ``;
}
this.differential = this.iswidth ? common_vendor.index.upx2px(this.width) : 0;
this.differential == 0 ? this.maskShow = false : ``;
}
},
close() {
if (this.maskShow) {
this.move = true;
this.differential = 0;
if (this.differential == 0) {
this.maskShow = false;
this.iswidth = false;
}
}
},
open() {
if (!this.maskShow) {
this.move = true;
this.differential = common_vendor.index.upx2px(this.width);
if (this.differential == common_vendor.index.upx2px(this.width)) {
this.maskShow = true;
this.iswidth = true;
}
}
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: $data.move ? 1 : "",
b: `${$props.width}rpx`,
c: `-${$props.width}rpx`,
d: `translate3d(${$data.differential}px,0,0)`,
e: `hidden`,
f: $data.maskShow,
g: common_vendor.o((...args) => $options.close && $options.close(...args)),
h: common_vendor.n($data.maskShow == true ? "container prevent" : "container")
};
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/third/ex-drawer/ex-drawer.js.map