UNPKG

@tencentcloud/roomkit-web-vue3

Version:

<h1 align="center"> TUIRoomKit</h1> Conference (TUIRoomKit) is a product suitable for multi-person audio and video conversation scenarios such as business meetings, webinars, and online education. By integrating this product, you can add room management,

80 lines (79 loc) 2.22 kB
var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); const eventMap = /* @__PURE__ */ new Map(); const TIME_OUT = 300; class VueTouch { constructor(el, binding) { __publicField(this, "dom"); __publicField(this, "callback"); __publicField(this, "isMove"); __publicField(this, "isInOnceTouch"); __publicField(this, "isLazyTap"); this.dom = el; this.callback = binding.value; this.isLazyTap = binding.modifiers.lazy; this.isMove = false; this.isInOnceTouch = false; el == null ? void 0 : el.addEventListener("touchstart", (event) => { if (binding.modifiers.stop) { event.stopPropagation(); } this.touchstart(event); }); el == null ? void 0 : el.addEventListener("touchmove", (event) => { if (binding.modifiers.stop) { event.stopPropagation(); } this.touchmove(); }); el == null ? void 0 : el.addEventListener("touchend", (event) => { if (binding.modifiers.stop) { event.stopPropagation(); } this.touchend(event); }); } touchstart(event) { if (event.touches.length > 1 || this.isInOnceTouch) { return; } this.isMove = false; this.isInOnceTouch = true; } touchmove() { if (!this.isInOnceTouch) { return; } this.isMove = true; this.isInOnceTouch = false; } touchend(event) { if (this.isMove || !this.isInOnceTouch) { return; } this.isInOnceTouch = false; if (this.isLazyTap) { if (eventMap.get(this.dom)) { clearTimeout(eventMap.get(this.dom)); eventMap.delete(this.dom); return; } const timer = setTimeout(() => { this.callback(event); eventMap.delete(this.dom); }, TIME_OUT); eventMap.set(this.dom, timer); } else { this.callback(event); } } } const vTap = { mounted(el, binding) { return new VueTouch(el, binding); } }; export { vTap as default };