hldy_app/unpackage/dist/dev/mp-weixin/component/public/newgame/arrowkeys.js

126 lines
5.0 KiB
JavaScript

"use strict";
const common_vendor = require("../../../common/vendor.js");
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "arrowkeys",
props: {
movebottom: { type: Number, default: 30 },
moveleft: { type: Number, default: 10 },
leftbuttonname: { type: String, default: "返回" },
rightbuttonname: { type: String, default: "确定" }
},
emits: ["movecard"],
setup(__props, { emit: __emit }) {
const emit = __emit;
let clickResetTimer = null;
let longPressTimer = null;
let isLongPress = false;
const beblue = common_vendor.ref(-1);
let activeLongPressDir = null;
function clearClickResetTimer() {
if (clickResetTimer) {
clearTimeout(clickResetTimer);
clickResetTimer = null;
}
}
function clearLongPressTimer() {
if (longPressTimer) {
clearTimeout(longPressTimer);
longPressTimer = null;
}
isLongPress = false;
activeLongPressDir = null;
}
function onTap(dir) {
clearLongPressTimer();
clearClickResetTimer();
beblue.value = dir;
emit("movecard", dir);
clickResetTimer = setTimeout(() => {
beblue.value = -1;
clickResetTimer = null;
}, 500);
}
function onLongPressStart(dir) {
clearClickResetTimer();
clearLongPressTimer();
beblue.value = dir;
emit("movecard", dir);
activeLongPressDir = dir;
isLongPress = true;
function loop() {
if (!isLongPress || activeLongPressDir === null)
return;
longPressTimer = setTimeout(loop, 500);
}
longPressTimer = setTimeout(loop, 500);
}
function onLongPressEnd() {
if (!isLongPress)
return;
clearLongPressTimer();
clearClickResetTimer();
clickResetTimer = setTimeout(() => {
beblue.value = -1;
clickResetTimer = null;
}, 500);
}
common_vendor.onBeforeUnmount(() => {
clearClickResetTimer();
clearLongPressTimer();
});
return (_ctx, _cache) => {
return {
a: `/static/index/newruler/${beblue.value === 5 ? 1 : 0}.png`,
b: common_vendor.t(__props.leftbuttonname),
c: common_vendor.n(beblue.value === 5 ? "grad-text" : ""),
d: common_vendor.n(beblue.value === 5 ? "click-box-target" : "click-box"),
e: common_vendor.o(($event) => onTap(5)),
f: common_vendor.o(() => onLongPressStart(5)),
g: common_vendor.o(onLongPressEnd),
h: common_vendor.o(onLongPressEnd),
i: `/static/index/newruler/${beblue.value === 0 ? 1 : 0}.png`,
j: `/static/index/newruler/fangxiang${beblue.value === 0 ? "target" : ""}.png`,
k: common_vendor.n(beblue.value === 0 ? "click-box-target" : "click-box"),
l: common_vendor.o(($event) => onTap(0)),
m: common_vendor.o(() => onLongPressStart(0)),
n: common_vendor.o(onLongPressEnd),
o: common_vendor.o(onLongPressEnd),
p: `/static/index/newruler/${beblue.value === 4 ? 1 : 0}.png`,
q: common_vendor.t(__props.rightbuttonname),
r: common_vendor.n(beblue.value === 4 ? "grad-text" : ""),
s: common_vendor.n(beblue.value === 4 ? "click-box-target" : "click-box"),
t: common_vendor.o(($event) => onTap(4)),
v: common_vendor.o(() => onLongPressStart(4)),
w: common_vendor.o(onLongPressEnd),
x: common_vendor.o(onLongPressEnd),
y: `/static/index/newruler/${beblue.value === 3 ? 1 : 0}.png`,
z: `/static/index/newruler/fangxiang${beblue.value === 3 ? "target" : ""}.png`,
A: common_vendor.n(beblue.value === 3 ? "click-box-target" : "click-box"),
B: common_vendor.o(($event) => onTap(3)),
C: common_vendor.o(() => onLongPressStart(3)),
D: common_vendor.o(onLongPressEnd),
E: common_vendor.o(onLongPressEnd),
F: `/static/index/newruler/${beblue.value === 2 ? 1 : 0}.png`,
G: `/static/index/newruler/fangxiang${beblue.value === 2 ? "target" : ""}.png`,
H: common_vendor.n(beblue.value === 2 ? "click-box-target" : "click-box"),
I: common_vendor.o(($event) => onTap(2)),
J: common_vendor.o(() => onLongPressStart(2)),
K: common_vendor.o(onLongPressEnd),
L: common_vendor.o(onLongPressEnd),
M: `/static/index/newruler/${beblue.value === 1 ? 1 : 0}.png`,
N: `/static/index/newruler/fangxiang${beblue.value === 1 ? "target" : ""}.png`,
O: common_vendor.n(beblue.value === 1 ? "click-box-target" : "click-box"),
P: common_vendor.o(($event) => onTap(1)),
Q: common_vendor.o(() => onLongPressStart(1)),
R: common_vendor.o(onLongPressEnd),
S: common_vendor.o(onLongPressEnd),
T: `${__props.movebottom}rpx`,
U: `${__props.moveleft}rpx`
};
};
}
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7e0708e6"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/component/public/newgame/arrowkeys.js.map