@rpg-engine/long-bow 0.7.98 → 0.7.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DPad/JoystickDPad.d.ts +2 -2
- package/dist/long-bow.cjs.development.js +206 -178
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +207 -179
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/DPad/JoystickDPad.tsx +270 -171
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
interface IDPadOptions {
|
|
3
3
|
/** Opacity of the entire component (0-1) */
|
|
4
4
|
opacity?: number;
|
|
@@ -17,5 +17,5 @@ interface IDPadProps {
|
|
|
17
17
|
/** Additional options for customizing the D-pad */
|
|
18
18
|
options?: IDPadOptions;
|
|
19
19
|
}
|
|
20
|
-
export declare const JoystickDPad: ({ onDirectionPress, disabled, options, }: IDPadProps) => JSX.Element
|
|
20
|
+
export declare const JoystickDPad: React.MemoExoticComponent<({ onDirectionPress, disabled, options, }: IDPadProps) => JSX.Element>;
|
|
21
21
|
export {};
|
|
@@ -29084,7 +29084,78 @@ var EmptyState = /*#__PURE__*/styled__default.div.withConfig({
|
|
|
29084
29084
|
componentId: "sc-19q95ue-15"
|
|
29085
29085
|
})(["position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;color:", ";width:100%;padding:2rem;svg{font-size:3rem;margin-bottom:1rem;opacity:0.7;}p{font-family:'Press Start 2P',cursive;font-size:0.9rem;margin:0;}"], uiColors.lightGray);
|
|
29086
29086
|
|
|
29087
|
-
|
|
29087
|
+
// Memoize the styled components since they don't depend on props that change frequently
|
|
29088
|
+
var DPadButton = /*#__PURE__*/React.memo( /*#__PURE__*/styled__default.div.withConfig({
|
|
29089
|
+
displayName: "JoystickDPad__DPadButton",
|
|
29090
|
+
componentId: "sc-q1e3gk-0"
|
|
29091
|
+
})(["position:absolute;background:", ";box-shadow:", ";cursor:", ";user-select:none;transition:all 0.08s cubic-bezier(0.4,0,0.2,1);touch-action:none;-webkit-tap-highlight-color:transparent;transform-origin:center center;&:hover:not(:active){@media (hover:hover){filter:", ";}}&::after{content:'';position:absolute;width:0;height:0;border:", "px solid transparent;pointer-events:none;opacity:", ";transition:all 0.08s cubic-bezier(0.4,0,0.2,1);}&.up,&.down{width:", "px;height:", "px;left:50%;transform:translateX(-50%) scale(", ");}&.left,&.right{width:", "px;height:", "px;top:50%;transform:translateY(-50%) scale(", ");}&.up{top:0;border-radius:5px 5px 0 0;&::after{border-bottom-color:#2a2a2a;top:45%;left:50%;transform:translate(-50%,-50%);}}&.down{bottom:0;border-radius:0 0 5px 5px;&::after{border-top-color:#2a2a2a;bottom:45%;left:50%;transform:translate(-50%,50%);}}&.left{left:0;border-radius:5px 0 0 5px;&::after{border-right-color:#2a2a2a;left:45%;top:50%;transform:translate(-50%,-50%);}}&.right{right:0;border-radius:0 5px 5px 0;&::after{border-left-color:#2a2a2a;right:45%;top:50%;transform:translate(50%,-50%);}}"], function (props) {
|
|
29092
|
+
return props.isPressed ? '#363636' : '#424242';
|
|
29093
|
+
}, function (props) {
|
|
29094
|
+
return props.isPressed ? 'inset 0 0 12px rgba(0, 0, 0, 0.8), 0 0 2px rgba(0, 0, 0, 0.3)' : 'inset 0 0 5px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.2)';
|
|
29095
|
+
}, function (props) {
|
|
29096
|
+
return props.disabled ? 'not-allowed' : 'pointer';
|
|
29097
|
+
}, function (props) {
|
|
29098
|
+
return !props.disabled && !props.isPressed ? 'brightness(1.1)' : 'none';
|
|
29099
|
+
}, function (props) {
|
|
29100
|
+
var _props$size;
|
|
29101
|
+
return ((_props$size = props.size) != null ? _props$size : 100) * 0.05;
|
|
29102
|
+
}, function (props) {
|
|
29103
|
+
return props.isPressed ? 0.7 : 1;
|
|
29104
|
+
}, function (props) {
|
|
29105
|
+
var _props$size2;
|
|
29106
|
+
return ((_props$size2 = props.size) != null ? _props$size2 : 100) * 0.3;
|
|
29107
|
+
}, function (props) {
|
|
29108
|
+
var _props$size3;
|
|
29109
|
+
return ((_props$size3 = props.size) != null ? _props$size3 : 100) * 0.4;
|
|
29110
|
+
}, function (props) {
|
|
29111
|
+
return props.isPressed ? 0.95 : 1;
|
|
29112
|
+
}, function (props) {
|
|
29113
|
+
var _props$size4;
|
|
29114
|
+
return ((_props$size4 = props.size) != null ? _props$size4 : 100) * 0.4;
|
|
29115
|
+
}, function (props) {
|
|
29116
|
+
var _props$size5;
|
|
29117
|
+
return ((_props$size5 = props.size) != null ? _props$size5 : 100) * 0.3;
|
|
29118
|
+
}, function (props) {
|
|
29119
|
+
return props.isPressed ? 0.95 : 1;
|
|
29120
|
+
}));
|
|
29121
|
+
var DPadCenter = /*#__PURE__*/React.memo( /*#__PURE__*/styled__default.div.withConfig({
|
|
29122
|
+
displayName: "JoystickDPad__DPadCenter",
|
|
29123
|
+
componentId: "sc-q1e3gk-1"
|
|
29124
|
+
})(["position:absolute;width:", "px;height:", "px;background:#424242;top:50%;left:50%;transform:translate(-50%,-50%);box-shadow:inset 0 0 8px rgba(0,0,0,0.6);border-radius:50%;user-select:none;cursor:", ";touch-action:none;-webkit-tap-highlight-color:transparent;&::after{content:'';position:absolute;width:", "px;height:", "px;background:#2a2a2a;border-radius:50%;top:50%;left:50%;transform:translate(-50%,-50%);pointer-events:none;box-shadow:inset 0 0 2px rgba(0,0,0,0.8);}"], function (props) {
|
|
29125
|
+
var _props$size6;
|
|
29126
|
+
return ((_props$size6 = props.size) != null ? _props$size6 : 100) * 0.3;
|
|
29127
|
+
}, function (props) {
|
|
29128
|
+
var _props$size7;
|
|
29129
|
+
return ((_props$size7 = props.size) != null ? _props$size7 : 100) * 0.3;
|
|
29130
|
+
}, function (props) {
|
|
29131
|
+
return props.disabled ? 'not-allowed' : 'default';
|
|
29132
|
+
}, function (props) {
|
|
29133
|
+
var _props$size8;
|
|
29134
|
+
return ((_props$size8 = props.size) != null ? _props$size8 : 100) * 0.08;
|
|
29135
|
+
}, function (props) {
|
|
29136
|
+
var _props$size9;
|
|
29137
|
+
return ((_props$size9 = props.size) != null ? _props$size9 : 100) * 0.08;
|
|
29138
|
+
}));
|
|
29139
|
+
var DPadContainer = /*#__PURE__*/React.memo( /*#__PURE__*/styled__default.div.withConfig({
|
|
29140
|
+
displayName: "JoystickDPad__DPadContainer",
|
|
29141
|
+
componentId: "sc-q1e3gk-2"
|
|
29142
|
+
})(["width:", "px;height:", "px;position:relative;background:", ";border-radius:50%;box-shadow:", ";opacity:", ";user-select:none;cursor:", ";transition:opacity 0.2s ease;touch-action:none;-webkit-tap-highlight-color:transparent;"], function (props) {
|
|
29143
|
+
var _props$size10;
|
|
29144
|
+
return (_props$size10 = props.size) != null ? _props$size10 : 100;
|
|
29145
|
+
}, function (props) {
|
|
29146
|
+
var _props$size11;
|
|
29147
|
+
return (_props$size11 = props.size) != null ? _props$size11 : 100;
|
|
29148
|
+
}, function (props) {
|
|
29149
|
+
return props.showBackground ? '#b8b8b8' : 'transparent';
|
|
29150
|
+
}, function (props) {
|
|
29151
|
+
return props.showBackground ? 'inset 0 0 10px rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2)' : 'none';
|
|
29152
|
+
}, function (props) {
|
|
29153
|
+
var _props$opacity;
|
|
29154
|
+
return props.disabled ? 0.5 : (_props$opacity = props.opacity) != null ? _props$opacity : 1;
|
|
29155
|
+
}, function (props) {
|
|
29156
|
+
return props.disabled ? 'not-allowed' : 'default';
|
|
29157
|
+
}));
|
|
29158
|
+
var JoystickDPad = /*#__PURE__*/React.memo(function (_ref) {
|
|
29088
29159
|
var onDirectionPress = _ref.onDirectionPress,
|
|
29089
29160
|
_ref$disabled = _ref.disabled,
|
|
29090
29161
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
@@ -29098,222 +29169,179 @@ var JoystickDPad = function JoystickDPad(_ref) {
|
|
|
29098
29169
|
size = _options$size === void 0 ? 100 : _options$size,
|
|
29099
29170
|
_options$pressInterva = options.pressInterval,
|
|
29100
29171
|
pressInterval = _options$pressInterva === void 0 ? 500 : _options$pressInterva;
|
|
29172
|
+
// Use refs for values that don't need to trigger re-renders
|
|
29101
29173
|
var _useState = React.useState(new Set()),
|
|
29102
29174
|
pressedButtons = _useState[0],
|
|
29103
29175
|
setPressedButtons = _useState[1];
|
|
29104
29176
|
var intervalRef = React.useRef(null);
|
|
29105
29177
|
var activeDirectionRef = React.useRef(null);
|
|
29178
|
+
var touchStartRef = React.useRef(null);
|
|
29179
|
+
var isPressedRef = React.useRef(false);
|
|
29106
29180
|
var clearPressInterval = React.useCallback(function () {
|
|
29107
|
-
if (intervalRef.current) {
|
|
29181
|
+
if (intervalRef.current !== null) {
|
|
29108
29182
|
window.clearInterval(intervalRef.current);
|
|
29109
29183
|
intervalRef.current = null;
|
|
29110
29184
|
}
|
|
29111
29185
|
activeDirectionRef.current = null;
|
|
29112
29186
|
}, []);
|
|
29187
|
+
var clearAllPresses = React.useCallback(function () {
|
|
29188
|
+
clearPressInterval();
|
|
29189
|
+
setPressedButtons(new Set());
|
|
29190
|
+
activeDirectionRef.current = null;
|
|
29191
|
+
isPressedRef.current = false;
|
|
29192
|
+
}, [clearPressInterval]);
|
|
29113
29193
|
var handleDirectionPress = React.useCallback(function (direction) {
|
|
29114
29194
|
if (disabled) return;
|
|
29115
|
-
// Clear any existing
|
|
29116
|
-
|
|
29117
|
-
// Set
|
|
29195
|
+
// Clear any existing presses first
|
|
29196
|
+
clearAllPresses();
|
|
29197
|
+
// Set new direction
|
|
29118
29198
|
activeDirectionRef.current = direction;
|
|
29119
|
-
|
|
29120
|
-
|
|
29121
|
-
});
|
|
29122
|
-
// Trigger first press immediately
|
|
29199
|
+
isPressedRef.current = true;
|
|
29200
|
+
setPressedButtons(new Set([direction]));
|
|
29123
29201
|
onDirectionPress == null ? void 0 : onDirectionPress(direction);
|
|
29124
|
-
// Set up the interval for continuous press
|
|
29125
29202
|
intervalRef.current = window.setInterval(function () {
|
|
29126
29203
|
if (activeDirectionRef.current === direction) {
|
|
29127
29204
|
onDirectionPress == null ? void 0 : onDirectionPress(direction);
|
|
29205
|
+
} else {
|
|
29206
|
+
clearPressInterval();
|
|
29128
29207
|
}
|
|
29129
29208
|
}, pressInterval);
|
|
29130
|
-
}, [disabled, onDirectionPress, pressInterval, clearPressInterval]);
|
|
29209
|
+
}, [disabled, onDirectionPress, pressInterval, clearPressInterval, clearAllPresses]);
|
|
29131
29210
|
var handleDirectionRelease = React.useCallback(function (direction) {
|
|
29132
|
-
setPressedButtons(function (prev) {
|
|
29133
|
-
var next = new Set(prev);
|
|
29134
|
-
next["delete"](direction);
|
|
29135
|
-
return next;
|
|
29136
|
-
});
|
|
29137
29211
|
if (activeDirectionRef.current === direction) {
|
|
29138
|
-
|
|
29212
|
+
clearAllPresses();
|
|
29139
29213
|
}
|
|
29140
|
-
}, [
|
|
29141
|
-
|
|
29214
|
+
}, [clearAllPresses]);
|
|
29215
|
+
var handleTouchStart = React.useCallback(function (e, direction) {
|
|
29216
|
+
var touch = e.touches[0];
|
|
29217
|
+
if (touch) {
|
|
29218
|
+
touchStartRef.current = {
|
|
29219
|
+
x: touch.clientX,
|
|
29220
|
+
y: touch.clientY
|
|
29221
|
+
};
|
|
29222
|
+
handleDirectionPress(direction);
|
|
29223
|
+
}
|
|
29224
|
+
}, [handleDirectionPress]);
|
|
29225
|
+
var handleTouchMove = React.useCallback(function (e) {
|
|
29226
|
+
var touch = e.touches[0];
|
|
29227
|
+
if (!touch || !touchStartRef.current) return;
|
|
29228
|
+
var _touchStartRef$curren = touchStartRef.current,
|
|
29229
|
+
startX = _touchStartRef$curren.x,
|
|
29230
|
+
startY = _touchStartRef$curren.y;
|
|
29231
|
+
var deltaX = touch.clientX - startX;
|
|
29232
|
+
var deltaY = touch.clientY - startY;
|
|
29233
|
+
// Calculate angle and distance
|
|
29234
|
+
var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
29235
|
+
var angle = Math.atan2(deltaY, deltaX) * (180 / Math.PI);
|
|
29236
|
+
// Only trigger if we've moved enough
|
|
29237
|
+
var threshold = size * 0.15; // Adaptive threshold based on d-pad size
|
|
29238
|
+
if (distance < threshold) return;
|
|
29239
|
+
var newDirection = null;
|
|
29240
|
+
// Determine direction based on angle
|
|
29241
|
+
if (angle > -45 && angle <= 45) newDirection = 'right';else if (angle > 45 && angle <= 135) newDirection = 'down';else if (angle > 135 || angle <= -135) newDirection = 'left';else if (angle > -135 && angle <= -45) newDirection = 'up';
|
|
29242
|
+
if (newDirection && newDirection !== activeDirectionRef.current) {
|
|
29243
|
+
handleDirectionPress(newDirection);
|
|
29244
|
+
// Update touch start to current position to prevent jitter
|
|
29245
|
+
touchStartRef.current = {
|
|
29246
|
+
x: touch.clientX,
|
|
29247
|
+
y: touch.clientY
|
|
29248
|
+
};
|
|
29249
|
+
}
|
|
29250
|
+
}, [handleDirectionPress, size]);
|
|
29251
|
+
// Add a new cleanup function for touch events
|
|
29252
|
+
var cleanupTouchEvents = React.useCallback(function () {
|
|
29253
|
+
touchStartRef.current = null;
|
|
29254
|
+
if (activeDirectionRef.current) {
|
|
29255
|
+
handleDirectionRelease(activeDirectionRef.current);
|
|
29256
|
+
}
|
|
29257
|
+
}, [handleDirectionRelease]);
|
|
29258
|
+
// Enhance the touch end handler
|
|
29259
|
+
var handleTouchEnd = React.useCallback(function () {
|
|
29260
|
+
cleanupTouchEvents();
|
|
29261
|
+
}, [cleanupTouchEvents]);
|
|
29262
|
+
// Add touch cancel handler
|
|
29263
|
+
var handleTouchCancel = React.useCallback(function () {
|
|
29264
|
+
cleanupTouchEvents();
|
|
29265
|
+
}, [cleanupTouchEvents]);
|
|
29266
|
+
// Enhance cleanup effect
|
|
29142
29267
|
React.useEffect(function () {
|
|
29268
|
+
if (disabled) {
|
|
29269
|
+
clearAllPresses();
|
|
29270
|
+
}
|
|
29271
|
+
var handleBlur = function handleBlur() {
|
|
29272
|
+
clearAllPresses();
|
|
29273
|
+
};
|
|
29274
|
+
var handleVisibilityChange = function handleVisibilityChange() {
|
|
29275
|
+
if (document.hidden) {
|
|
29276
|
+
clearAllPresses();
|
|
29277
|
+
}
|
|
29278
|
+
};
|
|
29279
|
+
var handlePointerUp = function handlePointerUp() {
|
|
29280
|
+
// Global pointer up as fallback for stuck buttons
|
|
29281
|
+
if (isPressedRef.current) {
|
|
29282
|
+
clearAllPresses();
|
|
29283
|
+
}
|
|
29284
|
+
};
|
|
29285
|
+
window.addEventListener('blur', handleBlur);
|
|
29286
|
+
window.addEventListener('pointerup', handlePointerUp);
|
|
29287
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
29143
29288
|
return function () {
|
|
29144
|
-
|
|
29289
|
+
clearAllPresses();
|
|
29290
|
+
window.removeEventListener('blur', handleBlur);
|
|
29291
|
+
window.removeEventListener('pointerup', handlePointerUp);
|
|
29292
|
+
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
29145
29293
|
};
|
|
29146
|
-
}, [
|
|
29147
|
-
|
|
29294
|
+
}, [disabled, clearAllPresses]);
|
|
29295
|
+
// Memoize the preventDefault handler
|
|
29296
|
+
var preventDefault = React.useCallback(function (e) {
|
|
29148
29297
|
e.preventDefault();
|
|
29149
29298
|
e.stopPropagation();
|
|
29150
|
-
};
|
|
29299
|
+
}, []);
|
|
29300
|
+
// Memoize button props to prevent unnecessary re-renders
|
|
29301
|
+
var buttonProps = React.useCallback(function (direction) {
|
|
29302
|
+
return {
|
|
29303
|
+
onMouseDown: function onMouseDown() {
|
|
29304
|
+
return handleDirectionPress(direction);
|
|
29305
|
+
},
|
|
29306
|
+
onMouseUp: function onMouseUp() {
|
|
29307
|
+
return handleDirectionRelease(direction);
|
|
29308
|
+
},
|
|
29309
|
+
onMouseLeave: function onMouseLeave() {
|
|
29310
|
+
return handleDirectionRelease(direction);
|
|
29311
|
+
},
|
|
29312
|
+
onTouchStart: function onTouchStart(e) {
|
|
29313
|
+
return handleTouchStart(e, direction);
|
|
29314
|
+
},
|
|
29315
|
+
onTouchMove: handleTouchMove,
|
|
29316
|
+
onTouchEnd: handleTouchEnd,
|
|
29317
|
+
onContextMenu: preventDefault,
|
|
29318
|
+
size: size,
|
|
29319
|
+
isPressed: pressedButtons.has(direction),
|
|
29320
|
+
disabled: disabled
|
|
29321
|
+
};
|
|
29322
|
+
}, [handleDirectionPress, handleDirectionRelease, handleTouchStart, handleTouchMove, handleTouchEnd, preventDefault, size, pressedButtons, disabled]);
|
|
29151
29323
|
return React__default.createElement(DPadContainer, {
|
|
29152
29324
|
opacity: opacity,
|
|
29153
29325
|
showBackground: showBackground,
|
|
29154
29326
|
size: size,
|
|
29155
29327
|
disabled: disabled,
|
|
29156
|
-
onContextMenu: preventDefault
|
|
29157
|
-
}, React__default.createElement(DPadButton, {
|
|
29158
|
-
className: "up",
|
|
29159
|
-
onMouseDown: function onMouseDown() {
|
|
29160
|
-
return handleDirectionPress('up');
|
|
29161
|
-
},
|
|
29162
|
-
onMouseUp: function onMouseUp() {
|
|
29163
|
-
return handleDirectionRelease('up');
|
|
29164
|
-
},
|
|
29165
|
-
onMouseLeave: function onMouseLeave() {
|
|
29166
|
-
return handleDirectionRelease('up');
|
|
29167
|
-
},
|
|
29168
|
-
onTouchStart: function onTouchStart() {
|
|
29169
|
-
return handleDirectionPress('up');
|
|
29170
|
-
},
|
|
29171
|
-
onTouchEnd: function onTouchEnd() {
|
|
29172
|
-
return handleDirectionRelease('up');
|
|
29173
|
-
},
|
|
29174
29328
|
onContextMenu: preventDefault,
|
|
29175
|
-
|
|
29176
|
-
|
|
29177
|
-
|
|
29178
|
-
}), React__default.createElement(DPadButton, {
|
|
29179
|
-
className: "right"
|
|
29180
|
-
|
|
29181
|
-
|
|
29182
|
-
|
|
29183
|
-
|
|
29184
|
-
|
|
29185
|
-
},
|
|
29186
|
-
onMouseLeave: function onMouseLeave() {
|
|
29187
|
-
return handleDirectionRelease('right');
|
|
29188
|
-
},
|
|
29189
|
-
onTouchStart: function onTouchStart() {
|
|
29190
|
-
return handleDirectionPress('right');
|
|
29191
|
-
},
|
|
29192
|
-
onTouchEnd: function onTouchEnd() {
|
|
29193
|
-
return handleDirectionRelease('right');
|
|
29194
|
-
},
|
|
29195
|
-
onContextMenu: preventDefault,
|
|
29196
|
-
size: size,
|
|
29197
|
-
isPressed: pressedButtons.has('right'),
|
|
29198
|
-
disabled: disabled
|
|
29199
|
-
}), React__default.createElement(DPadButton, {
|
|
29200
|
-
className: "down",
|
|
29201
|
-
onMouseDown: function onMouseDown() {
|
|
29202
|
-
return handleDirectionPress('down');
|
|
29203
|
-
},
|
|
29204
|
-
onMouseUp: function onMouseUp() {
|
|
29205
|
-
return handleDirectionRelease('down');
|
|
29206
|
-
},
|
|
29207
|
-
onMouseLeave: function onMouseLeave() {
|
|
29208
|
-
return handleDirectionRelease('down');
|
|
29209
|
-
},
|
|
29210
|
-
onTouchStart: function onTouchStart() {
|
|
29211
|
-
return handleDirectionPress('down');
|
|
29212
|
-
},
|
|
29213
|
-
onTouchEnd: function onTouchEnd() {
|
|
29214
|
-
return handleDirectionRelease('down');
|
|
29215
|
-
},
|
|
29216
|
-
onContextMenu: preventDefault,
|
|
29217
|
-
size: size,
|
|
29218
|
-
isPressed: pressedButtons.has('down'),
|
|
29219
|
-
disabled: disabled
|
|
29220
|
-
}), React__default.createElement(DPadButton, {
|
|
29221
|
-
className: "left",
|
|
29222
|
-
onMouseDown: function onMouseDown() {
|
|
29223
|
-
return handleDirectionPress('left');
|
|
29224
|
-
},
|
|
29225
|
-
onMouseUp: function onMouseUp() {
|
|
29226
|
-
return handleDirectionRelease('left');
|
|
29227
|
-
},
|
|
29228
|
-
onMouseLeave: function onMouseLeave() {
|
|
29229
|
-
return handleDirectionRelease('left');
|
|
29230
|
-
},
|
|
29231
|
-
onTouchStart: function onTouchStart() {
|
|
29232
|
-
return handleDirectionPress('left');
|
|
29233
|
-
},
|
|
29234
|
-
onTouchEnd: function onTouchEnd() {
|
|
29235
|
-
return handleDirectionRelease('left');
|
|
29236
|
-
},
|
|
29237
|
-
onContextMenu: preventDefault,
|
|
29238
|
-
size: size,
|
|
29239
|
-
isPressed: pressedButtons.has('left'),
|
|
29240
|
-
disabled: disabled
|
|
29241
|
-
}), React__default.createElement(DPadCenter, {
|
|
29329
|
+
onTouchCancel: handleTouchCancel
|
|
29330
|
+
}, React__default.createElement(DPadButton, Object.assign({
|
|
29331
|
+
className: "up"
|
|
29332
|
+
}, buttonProps('up'))), React__default.createElement(DPadButton, Object.assign({
|
|
29333
|
+
className: "right"
|
|
29334
|
+
}, buttonProps('right'))), React__default.createElement(DPadButton, Object.assign({
|
|
29335
|
+
className: "down"
|
|
29336
|
+
}, buttonProps('down'))), React__default.createElement(DPadButton, Object.assign({
|
|
29337
|
+
className: "left"
|
|
29338
|
+
}, buttonProps('left'))), React__default.createElement(DPadCenter, {
|
|
29242
29339
|
size: size,
|
|
29243
29340
|
disabled: disabled,
|
|
29244
29341
|
onContextMenu: preventDefault
|
|
29245
29342
|
}));
|
|
29246
|
-
};
|
|
29247
|
-
var DPadContainer = /*#__PURE__*/styled__default.div.withConfig({
|
|
29248
|
-
displayName: "JoystickDPad__DPadContainer",
|
|
29249
|
-
componentId: "sc-q1e3gk-0"
|
|
29250
|
-
})(["width:", "px;height:", "px;position:relative;background:", ";border-radius:50%;box-shadow:", ";opacity:", ";user-select:none;cursor:", ";transition:opacity 0.2s ease;touch-action:none;-webkit-tap-highlight-color:transparent;"], function (props) {
|
|
29251
|
-
var _props$size;
|
|
29252
|
-
return (_props$size = props.size) != null ? _props$size : 100;
|
|
29253
|
-
}, function (props) {
|
|
29254
|
-
var _props$size2;
|
|
29255
|
-
return (_props$size2 = props.size) != null ? _props$size2 : 100;
|
|
29256
|
-
}, function (props) {
|
|
29257
|
-
return props.showBackground ? '#b8b8b8' : 'transparent';
|
|
29258
|
-
}, function (props) {
|
|
29259
|
-
return props.showBackground ? 'inset 0 0 10px rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2)' : 'none';
|
|
29260
|
-
}, function (props) {
|
|
29261
|
-
var _props$opacity;
|
|
29262
|
-
return props.disabled ? 0.5 : (_props$opacity = props.opacity) != null ? _props$opacity : 1;
|
|
29263
|
-
}, function (props) {
|
|
29264
|
-
return props.disabled ? 'not-allowed' : 'default';
|
|
29265
|
-
});
|
|
29266
|
-
var DPadButton = /*#__PURE__*/styled__default.div.withConfig({
|
|
29267
|
-
displayName: "JoystickDPad__DPadButton",
|
|
29268
|
-
componentId: "sc-q1e3gk-1"
|
|
29269
|
-
})(["position:absolute;background:", ";box-shadow:", ";cursor:", ";user-select:none;transition:all 0.08s cubic-bezier(0.4,0,0.2,1);touch-action:none;-webkit-tap-highlight-color:transparent;transform-origin:center center;&:hover:not(:active){@media (hover:hover){filter:", ";}}&::after{content:'';position:absolute;width:0;height:0;border:", "px solid transparent;pointer-events:none;opacity:", ";transition:all 0.08s cubic-bezier(0.4,0,0.2,1);}&.up,&.down{width:", "px;height:", "px;left:50%;transform:translateX(-50%) scale(", ");}&.left,&.right{width:", "px;height:", "px;top:50%;transform:translateY(-50%) scale(", ");}&.up{top:0;border-radius:5px 5px 0 0;&::after{border-bottom-color:#2a2a2a;top:45%;left:50%;transform:translate(-50%,-50%);}}&.down{bottom:0;border-radius:0 0 5px 5px;&::after{border-top-color:#2a2a2a;bottom:45%;left:50%;transform:translate(-50%,50%);}}&.left{left:0;border-radius:5px 0 0 5px;&::after{border-right-color:#2a2a2a;left:45%;top:50%;transform:translate(-50%,-50%);}}&.right{right:0;border-radius:0 5px 5px 0;&::after{border-left-color:#2a2a2a;right:45%;top:50%;transform:translate(50%,-50%);}}"], function (props) {
|
|
29270
|
-
return props.isPressed ? '#363636' : '#424242';
|
|
29271
|
-
}, function (props) {
|
|
29272
|
-
return props.isPressed ? 'inset 0 0 12px rgba(0, 0, 0, 0.8), 0 0 2px rgba(0, 0, 0, 0.3)' : 'inset 0 0 5px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.2)';
|
|
29273
|
-
}, function (props) {
|
|
29274
|
-
return props.disabled ? 'not-allowed' : 'pointer';
|
|
29275
|
-
}, function (props) {
|
|
29276
|
-
return !props.disabled && !props.isPressed ? 'brightness(1.1)' : 'none';
|
|
29277
|
-
}, function (props) {
|
|
29278
|
-
var _props$size3;
|
|
29279
|
-
return ((_props$size3 = props.size) != null ? _props$size3 : 100) * 0.05;
|
|
29280
|
-
}, function (props) {
|
|
29281
|
-
return props.isPressed ? 0.7 : 1;
|
|
29282
|
-
}, function (props) {
|
|
29283
|
-
var _props$size4;
|
|
29284
|
-
return ((_props$size4 = props.size) != null ? _props$size4 : 100) * 0.3;
|
|
29285
|
-
}, function (props) {
|
|
29286
|
-
var _props$size5;
|
|
29287
|
-
return ((_props$size5 = props.size) != null ? _props$size5 : 100) * 0.4;
|
|
29288
|
-
}, function (props) {
|
|
29289
|
-
return props.isPressed ? 0.95 : 1;
|
|
29290
|
-
}, function (props) {
|
|
29291
|
-
var _props$size6;
|
|
29292
|
-
return ((_props$size6 = props.size) != null ? _props$size6 : 100) * 0.4;
|
|
29293
|
-
}, function (props) {
|
|
29294
|
-
var _props$size7;
|
|
29295
|
-
return ((_props$size7 = props.size) != null ? _props$size7 : 100) * 0.3;
|
|
29296
|
-
}, function (props) {
|
|
29297
|
-
return props.isPressed ? 0.95 : 1;
|
|
29298
|
-
});
|
|
29299
|
-
var DPadCenter = /*#__PURE__*/styled__default.div.withConfig({
|
|
29300
|
-
displayName: "JoystickDPad__DPadCenter",
|
|
29301
|
-
componentId: "sc-q1e3gk-2"
|
|
29302
|
-
})(["position:absolute;width:", "px;height:", "px;background:#424242;top:50%;left:50%;transform:translate(-50%,-50%);box-shadow:inset 0 0 8px rgba(0,0,0,0.6);border-radius:50%;user-select:none;cursor:", ";touch-action:none;-webkit-tap-highlight-color:transparent;&::after{content:'';position:absolute;width:", "px;height:", "px;background:#2a2a2a;border-radius:50%;top:50%;left:50%;transform:translate(-50%,-50%);pointer-events:none;box-shadow:inset 0 0 2px rgba(0,0,0,0.8);}"], function (props) {
|
|
29303
|
-
var _props$size8;
|
|
29304
|
-
return ((_props$size8 = props.size) != null ? _props$size8 : 100) * 0.3;
|
|
29305
|
-
}, function (props) {
|
|
29306
|
-
var _props$size9;
|
|
29307
|
-
return ((_props$size9 = props.size) != null ? _props$size9 : 100) * 0.3;
|
|
29308
|
-
}, function (props) {
|
|
29309
|
-
return props.disabled ? 'not-allowed' : 'default';
|
|
29310
|
-
}, function (props) {
|
|
29311
|
-
var _props$size10;
|
|
29312
|
-
return ((_props$size10 = props.size) != null ? _props$size10 : 100) * 0.08;
|
|
29313
|
-
}, function (props) {
|
|
29314
|
-
var _props$size11;
|
|
29315
|
-
return ((_props$size11 = props.size) != null ? _props$size11 : 100) * 0.08;
|
|
29316
29343
|
});
|
|
29344
|
+
JoystickDPad.displayName = 'JoystickDPad';
|
|
29317
29345
|
|
|
29318
29346
|
var DropdownSelectorContainer = function DropdownSelectorContainer(_ref) {
|
|
29319
29347
|
var title = _ref.title,
|