"use strict"; const common_vendor = require("../../../common/vendor.js"); const common_assets = require("../../../common/assets.js"); const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ __name: "joysticknew", props: { getblue: { type: Boolean, default: false }, movebottom: { type: Number, default: 0 }, moveright: { type: Number, default: 110 }, pao: { type: Boolean, default: true }, notext: { type: Boolean, default: false } }, emits: ["movecard"], setup(__props, { emit: __emit }) { const emit = __emit; const key = common_vendor.ref(-1); let clickResetTimer = null; let longPressInterval = null; let isLongPress = false; const type = common_vendor.ref(-1); const shadow = common_vendor.reactive({ x: 0, y: 0 }); const showShadow = common_vendor.ref(false); const showRippleOnce = common_vendor.ref(false); const rippleKey = common_vendor.ref(0); const RADIUS = common_vendor.index.upx2px(175); const DIAMETER = common_vendor.index.upx2px(350); common_vendor.index.upx2px(-50); const BOTTOM = common_vendor.index.upx2px(100); const windowHeight = common_vendor.index.getSystemInfoSync().windowHeight; const TOP = windowHeight - BOTTOM - DIAMETER; const props = __props; const getblue = common_vendor.ref(false); const pulseKey = common_vendor.ref(0); common_vendor.ref(0); common_vendor.watch(() => props.getblue, (val) => { }); common_vendor.onBeforeUnmount(() => { }); function onTap(dir, e) { if (isLongPress) return; clearClickTimer(); key.value = dir; emit("movecard", dir); if ((e == null ? void 0 : e.touches) && e.touches.length) { const touch = e.touches[0]; updateShadowPosition(touch.pageX, touch.pageY); } showRippleOnce.value = false; rippleKey.value++; type.value = dir; setTimeout(() => { type.value = -1; }, 300); setTimeout(() => { showRippleOnce.value = true; }, 16); clickResetTimer = setTimeout(() => { key.value = -1; clickResetTimer = null; }, 300); } function onLongPressStart(dir, e) { clearLongPressInterval(); isLongPress = true; showShadow.value = true; type.value = dir; const touch = ((e == null ? void 0 : e.touches) || [])[0]; if (touch) updateShadowPosition(touch.pageX, touch.pageY); key.value = dir; emit("movecard", dir); longPressInterval = setInterval(() => { key.value = dir; emit("movecard", dir); }, 500); } function onPressEnd() { clearClickTimer(); clearLongPressInterval(); isLongPress = false; showShadow.value = false; key.value = -1; type.value = -1; } function clearClickTimer() { if (clickResetTimer) { clearTimeout(clickResetTimer); clickResetTimer = null; } } function clearLongPressInterval() { if (longPressInterval) { clearInterval(longPressInterval); longPressInterval = null; } } function updateShadowPosition(pageX, pageY) { let x = pageX; let y = pageY - TOP - 50 + props.movebottom / 2; const dx = x - RADIUS; const dy = y - RADIUS; const dist = Math.sqrt(dx * dx + dy * dy); if (dist > RADIUS) { const angle = Math.atan2(dy, dx); x = RADIUS + RADIUS * Math.cos(angle); y = RADIUS + RADIUS * Math.sin(angle); } shadow.x = x; shadow.y = y; } function onTouchMove(e) { var _a; if (!isLongPress) return; const touch = (((_a = e.detail) == null ? void 0 : _a.touches) || e.touches || [])[0]; if (!touch) return; updateShadowPosition(touch.pageX, touch.pageY); } return (_ctx, _cache) => { return common_vendor.e({ a: common_assets._imports_0$12, b: type.value == -1 || type.value == 4, c: common_assets._imports_1$8, d: type.value == 3, e: common_assets._imports_2$6, f: type.value == 2, g: common_assets._imports_3$4, h: type.value == 0, i: common_assets._imports_4$3, j: type.value == 1, k: getblue.value }, getblue.value ? { l: pulseKey.value } : {}, { m: common_vendor.o(($event) => onTap(0, $event)), n: common_vendor.o((e) => onLongPressStart(0, e)), o: common_vendor.o(($event) => onTap(3, $event)), p: common_vendor.o((e) => onLongPressStart(3, e)), q: common_vendor.o(($event) => onTap(2, $event)), r: common_vendor.o((e) => onLongPressStart(2, e)), s: common_vendor.o(($event) => onTap(1, $event)), t: common_vendor.o((e) => onLongPressStart(1, e)), v: common_vendor.o(($event) => onTap(4, $event)), w: common_vendor.o((e) => onLongPressStart(4, e)), x: `${__props.movebottom}rpx`, y: `${__props.moveright}rpx`, z: common_vendor.o(onTouchMove), A: common_vendor.o(onPressEnd), B: common_vendor.o(onPressEnd) }); }; } }); const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-e20c63a2"]]); wx.createComponent(Component); //# sourceMappingURL=../../../../.sourcemap/mp-weixin/component/public/newgame/joysticknew.js.map