react-simple-game-engine 0.3.35 → 0.3.36

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,21 +48,29 @@ export function MovementControl(_a) {
48
48
  }
49
49
  };
50
50
  var joystick = (_jsx(Joystick, __assign({ size: 60, baseColor: "#2D2D2D", stickColor: "rgb(120,121,122)", throttle: 100 }, props, { start: onAction, move: onAction, stop: onAction })));
51
+ var isReleased = false;
52
+ var handleTouchDown = function () {
53
+ var _a, _b, _c;
54
+ isReleased = false;
55
+ (_a = containerTouchEvent === null || containerTouchEvent === void 0 ? void 0 : containerTouchEvent.onPressed) === null || _a === void 0 ? void 0 : _a.call(containerTouchEvent, refJoyWrap.current, refStick.current);
56
+ (_c = (_b = joystickConfigs === null || joystickConfigs === void 0 ? void 0 : joystickConfigs.containerTouchEvent) === null || _b === void 0 ? void 0 : _b.onPressed) === null || _c === void 0 ? void 0 : _c.call(_b, refJoyWrap.current, refStick.current);
57
+ };
58
+ var handleTouchUp = function () {
59
+ var _a, _b, _c;
60
+ if (isReleased) {
61
+ return;
62
+ }
63
+ isReleased = true;
64
+ (_a = containerTouchEvent === null || containerTouchEvent === void 0 ? void 0 : containerTouchEvent.onReleased) === null || _a === void 0 ? void 0 : _a.call(containerTouchEvent, refJoyWrap.current, refStick.current);
65
+ (_c = (_b = joystickConfigs === null || joystickConfigs === void 0 ? void 0 : joystickConfigs.containerTouchEvent) === null || _b === void 0 ? void 0 : _b.onReleased) === null || _c === void 0 ? void 0 : _c.call(_b, refJoyWrap.current, refStick.current);
66
+ };
51
67
  return (_jsx("div", __assign({ ref: refJoyWrap, onPointerDown: function (event) {
52
- var _a, _b, _c;
53
68
  event.target.setPointerCapture(event.pointerId);
54
- (_a = containerTouchEvent === null || containerTouchEvent === void 0 ? void 0 : containerTouchEvent.onPressed) === null || _a === void 0 ? void 0 : _a.call(containerTouchEvent, refJoyWrap.current, refStick.current);
55
- (_c = (_b = joystickConfigs === null || joystickConfigs === void 0 ? void 0 : joystickConfigs.containerTouchEvent) === null || _b === void 0 ? void 0 : _b.onPressed) === null || _c === void 0 ? void 0 : _c.call(_b, refJoyWrap.current, refStick.current);
69
+ handleTouchDown();
56
70
  }, onPointerUp: function (event) {
57
- var _a, _b, _c;
58
71
  event.target.releasePointerCapture(event.pointerId);
59
- (_a = containerTouchEvent === null || containerTouchEvent === void 0 ? void 0 : containerTouchEvent.onReleased) === null || _a === void 0 ? void 0 : _a.call(containerTouchEvent, refJoyWrap.current, refStick.current);
60
- (_c = (_b = joystickConfigs === null || joystickConfigs === void 0 ? void 0 : joystickConfigs.containerTouchEvent) === null || _b === void 0 ? void 0 : _b.onReleased) === null || _c === void 0 ? void 0 : _c.call(_b, refJoyWrap.current, refStick.current);
61
- }, onMouseLeave: function () {
62
- var _a, _b, _c;
63
- (_a = containerTouchEvent === null || containerTouchEvent === void 0 ? void 0 : containerTouchEvent.onReleased) === null || _a === void 0 ? void 0 : _a.call(containerTouchEvent, refJoyWrap.current, refStick.current);
64
- (_c = (_b = joystickConfigs === null || joystickConfigs === void 0 ? void 0 : joystickConfigs.containerTouchEvent) === null || _b === void 0 ? void 0 : _b.onReleased) === null || _c === void 0 ? void 0 : _c.call(_b, refJoyWrap.current, refStick.current);
65
- }, style: {
72
+ handleTouchUp();
73
+ }, onMouseLeave: handleTouchUp, style: {
66
74
  position: "absolute",
67
75
  left: right != null ? undefined : left,
68
76
  right: right,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-simple-game-engine",
3
- "version": "0.3.35",
3
+ "version": "0.3.36",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib",