@rpg-engine/long-bow 0.7.98 → 0.8.0
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 +4 -2
- package/dist/long-bow.cjs.development.js +210 -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 +211 -179
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/DPad/JoystickDPad.tsx +276 -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;
|
|
@@ -12,10 +12,12 @@ interface IDPadOptions {
|
|
|
12
12
|
interface IDPadProps {
|
|
13
13
|
/** Callback fired when a direction is pressed */
|
|
14
14
|
onDirectionPress?: (direction: 'up' | 'down' | 'left' | 'right') => void;
|
|
15
|
+
/** Callback fired when a direction is released */
|
|
16
|
+
onDirectionRelease?: (direction: 'up' | 'down' | 'left' | 'right') => void;
|
|
15
17
|
/** Whether the component is disabled */
|
|
16
18
|
disabled?: boolean;
|
|
17
19
|
/** Additional options for customizing the D-pad */
|
|
18
20
|
options?: IDPadOptions;
|
|
19
21
|
}
|
|
20
|
-
export declare const JoystickDPad: ({ onDirectionPress, disabled, options, }: IDPadProps) => JSX.Element
|
|
22
|
+
export declare const JoystickDPad: React.MemoExoticComponent<({ onDirectionPress, onDirectionRelease, disabled, options, }: IDPadProps) => JSX.Element>;
|
|
21
23
|
export {};
|
|
@@ -29084,8 +29084,80 @@ 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,
|
|
29160
|
+
onDirectionRelease = _ref.onDirectionRelease,
|
|
29089
29161
|
_ref$disabled = _ref.disabled,
|
|
29090
29162
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
29091
29163
|
_ref$options = _ref.options,
|
|
@@ -29098,222 +29170,182 @@ var JoystickDPad = function JoystickDPad(_ref) {
|
|
|
29098
29170
|
size = _options$size === void 0 ? 100 : _options$size,
|
|
29099
29171
|
_options$pressInterva = options.pressInterval,
|
|
29100
29172
|
pressInterval = _options$pressInterva === void 0 ? 500 : _options$pressInterva;
|
|
29173
|
+
// Use refs for values that don't need to trigger re-renders
|
|
29101
29174
|
var _useState = React.useState(new Set()),
|
|
29102
29175
|
pressedButtons = _useState[0],
|
|
29103
29176
|
setPressedButtons = _useState[1];
|
|
29104
29177
|
var intervalRef = React.useRef(null);
|
|
29105
29178
|
var activeDirectionRef = React.useRef(null);
|
|
29179
|
+
var touchStartRef = React.useRef(null);
|
|
29180
|
+
var isPressedRef = React.useRef(false);
|
|
29106
29181
|
var clearPressInterval = React.useCallback(function () {
|
|
29107
|
-
if (intervalRef.current) {
|
|
29182
|
+
if (intervalRef.current !== null) {
|
|
29108
29183
|
window.clearInterval(intervalRef.current);
|
|
29109
29184
|
intervalRef.current = null;
|
|
29110
29185
|
}
|
|
29111
29186
|
activeDirectionRef.current = null;
|
|
29112
29187
|
}, []);
|
|
29188
|
+
var clearAllPresses = React.useCallback(function () {
|
|
29189
|
+
if (activeDirectionRef.current && onDirectionRelease) {
|
|
29190
|
+
onDirectionRelease(activeDirectionRef.current);
|
|
29191
|
+
}
|
|
29192
|
+
clearPressInterval();
|
|
29193
|
+
setPressedButtons(new Set());
|
|
29194
|
+
activeDirectionRef.current = null;
|
|
29195
|
+
isPressedRef.current = false;
|
|
29196
|
+
}, [clearPressInterval, onDirectionRelease]);
|
|
29113
29197
|
var handleDirectionPress = React.useCallback(function (direction) {
|
|
29114
29198
|
if (disabled) return;
|
|
29115
|
-
// Clear any existing
|
|
29116
|
-
|
|
29117
|
-
// Set
|
|
29199
|
+
// Clear any existing presses first
|
|
29200
|
+
clearAllPresses();
|
|
29201
|
+
// Set new direction
|
|
29118
29202
|
activeDirectionRef.current = direction;
|
|
29119
|
-
|
|
29120
|
-
|
|
29121
|
-
});
|
|
29122
|
-
// Trigger first press immediately
|
|
29203
|
+
isPressedRef.current = true;
|
|
29204
|
+
setPressedButtons(new Set([direction]));
|
|
29123
29205
|
onDirectionPress == null ? void 0 : onDirectionPress(direction);
|
|
29124
|
-
// Set up the interval for continuous press
|
|
29125
29206
|
intervalRef.current = window.setInterval(function () {
|
|
29126
29207
|
if (activeDirectionRef.current === direction) {
|
|
29127
29208
|
onDirectionPress == null ? void 0 : onDirectionPress(direction);
|
|
29209
|
+
} else {
|
|
29210
|
+
clearPressInterval();
|
|
29128
29211
|
}
|
|
29129
29212
|
}, pressInterval);
|
|
29130
|
-
}, [disabled, onDirectionPress, pressInterval, clearPressInterval]);
|
|
29213
|
+
}, [disabled, onDirectionPress, pressInterval, clearPressInterval, clearAllPresses]);
|
|
29131
29214
|
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
29215
|
if (activeDirectionRef.current === direction) {
|
|
29138
|
-
|
|
29216
|
+
clearAllPresses();
|
|
29217
|
+
}
|
|
29218
|
+
}, [clearAllPresses]);
|
|
29219
|
+
var handleTouchStart = React.useCallback(function (e, direction) {
|
|
29220
|
+
var touch = e.touches[0];
|
|
29221
|
+
if (touch) {
|
|
29222
|
+
touchStartRef.current = {
|
|
29223
|
+
x: touch.clientX,
|
|
29224
|
+
y: touch.clientY
|
|
29225
|
+
};
|
|
29226
|
+
handleDirectionPress(direction);
|
|
29139
29227
|
}
|
|
29140
|
-
}, [
|
|
29141
|
-
|
|
29228
|
+
}, [handleDirectionPress]);
|
|
29229
|
+
var handleTouchMove = React.useCallback(function (e) {
|
|
29230
|
+
var touch = e.touches[0];
|
|
29231
|
+
if (!touch || !touchStartRef.current) return;
|
|
29232
|
+
var _touchStartRef$curren = touchStartRef.current,
|
|
29233
|
+
startX = _touchStartRef$curren.x,
|
|
29234
|
+
startY = _touchStartRef$curren.y;
|
|
29235
|
+
var deltaX = touch.clientX - startX;
|
|
29236
|
+
var deltaY = touch.clientY - startY;
|
|
29237
|
+
// Calculate angle and distance
|
|
29238
|
+
var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
29239
|
+
var angle = Math.atan2(deltaY, deltaX) * (180 / Math.PI);
|
|
29240
|
+
// Only trigger if we've moved enough
|
|
29241
|
+
var threshold = size * 0.15; // Adaptive threshold based on d-pad size
|
|
29242
|
+
if (distance < threshold) return;
|
|
29243
|
+
var newDirection = null;
|
|
29244
|
+
// Determine direction based on angle
|
|
29245
|
+
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';
|
|
29246
|
+
if (newDirection && newDirection !== activeDirectionRef.current) {
|
|
29247
|
+
handleDirectionPress(newDirection);
|
|
29248
|
+
// Update touch start to current position to prevent jitter
|
|
29249
|
+
touchStartRef.current = {
|
|
29250
|
+
x: touch.clientX,
|
|
29251
|
+
y: touch.clientY
|
|
29252
|
+
};
|
|
29253
|
+
}
|
|
29254
|
+
}, [handleDirectionPress, size]);
|
|
29255
|
+
// Add a new cleanup function for touch events
|
|
29256
|
+
var cleanupTouchEvents = React.useCallback(function () {
|
|
29257
|
+
touchStartRef.current = null;
|
|
29258
|
+
if (activeDirectionRef.current) {
|
|
29259
|
+
handleDirectionRelease(activeDirectionRef.current);
|
|
29260
|
+
}
|
|
29261
|
+
}, [handleDirectionRelease]);
|
|
29262
|
+
// Enhance the touch end handler
|
|
29263
|
+
var handleTouchEnd = React.useCallback(function () {
|
|
29264
|
+
cleanupTouchEvents();
|
|
29265
|
+
}, [cleanupTouchEvents]);
|
|
29266
|
+
// Add touch cancel handler
|
|
29267
|
+
var handleTouchCancel = React.useCallback(function () {
|
|
29268
|
+
cleanupTouchEvents();
|
|
29269
|
+
}, [cleanupTouchEvents]);
|
|
29270
|
+
// Enhance cleanup effect
|
|
29142
29271
|
React.useEffect(function () {
|
|
29272
|
+
if (disabled) {
|
|
29273
|
+
clearAllPresses();
|
|
29274
|
+
}
|
|
29275
|
+
var handleBlur = function handleBlur() {
|
|
29276
|
+
clearAllPresses();
|
|
29277
|
+
};
|
|
29278
|
+
var handleVisibilityChange = function handleVisibilityChange() {
|
|
29279
|
+
if (document.hidden) {
|
|
29280
|
+
clearAllPresses();
|
|
29281
|
+
}
|
|
29282
|
+
};
|
|
29283
|
+
var handlePointerUp = function handlePointerUp() {
|
|
29284
|
+
// Global pointer up as fallback for stuck buttons
|
|
29285
|
+
if (isPressedRef.current) {
|
|
29286
|
+
clearAllPresses();
|
|
29287
|
+
}
|
|
29288
|
+
};
|
|
29289
|
+
window.addEventListener('blur', handleBlur);
|
|
29290
|
+
window.addEventListener('pointerup', handlePointerUp);
|
|
29291
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
29143
29292
|
return function () {
|
|
29144
|
-
|
|
29293
|
+
clearAllPresses();
|
|
29294
|
+
window.removeEventListener('blur', handleBlur);
|
|
29295
|
+
window.removeEventListener('pointerup', handlePointerUp);
|
|
29296
|
+
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
29145
29297
|
};
|
|
29146
|
-
}, [
|
|
29147
|
-
|
|
29298
|
+
}, [disabled, clearAllPresses]);
|
|
29299
|
+
// Memoize the preventDefault handler
|
|
29300
|
+
var preventDefault = React.useCallback(function (e) {
|
|
29148
29301
|
e.preventDefault();
|
|
29149
29302
|
e.stopPropagation();
|
|
29150
|
-
};
|
|
29303
|
+
}, []);
|
|
29304
|
+
// Memoize button props to prevent unnecessary re-renders
|
|
29305
|
+
var buttonProps = React.useCallback(function (direction) {
|
|
29306
|
+
return {
|
|
29307
|
+
onMouseDown: function onMouseDown() {
|
|
29308
|
+
return handleDirectionPress(direction);
|
|
29309
|
+
},
|
|
29310
|
+
onMouseUp: function onMouseUp() {
|
|
29311
|
+
return handleDirectionRelease(direction);
|
|
29312
|
+
},
|
|
29313
|
+
onMouseLeave: function onMouseLeave() {
|
|
29314
|
+
return handleDirectionRelease(direction);
|
|
29315
|
+
},
|
|
29316
|
+
onTouchStart: function onTouchStart(e) {
|
|
29317
|
+
return handleTouchStart(e, direction);
|
|
29318
|
+
},
|
|
29319
|
+
onTouchMove: handleTouchMove,
|
|
29320
|
+
onTouchEnd: handleTouchEnd,
|
|
29321
|
+
onContextMenu: preventDefault,
|
|
29322
|
+
size: size,
|
|
29323
|
+
isPressed: pressedButtons.has(direction),
|
|
29324
|
+
disabled: disabled
|
|
29325
|
+
};
|
|
29326
|
+
}, [handleDirectionPress, handleDirectionRelease, handleTouchStart, handleTouchMove, handleTouchEnd, preventDefault, size, pressedButtons, disabled]);
|
|
29151
29327
|
return React__default.createElement(DPadContainer, {
|
|
29152
29328
|
opacity: opacity,
|
|
29153
29329
|
showBackground: showBackground,
|
|
29154
29330
|
size: size,
|
|
29155
29331
|
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
29332
|
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, {
|
|
29333
|
+
onTouchCancel: handleTouchCancel
|
|
29334
|
+
}, React__default.createElement(DPadButton, Object.assign({
|
|
29335
|
+
className: "up"
|
|
29336
|
+
}, buttonProps('up'))), React__default.createElement(DPadButton, Object.assign({
|
|
29337
|
+
className: "right"
|
|
29338
|
+
}, buttonProps('right'))), React__default.createElement(DPadButton, Object.assign({
|
|
29339
|
+
className: "down"
|
|
29340
|
+
}, buttonProps('down'))), React__default.createElement(DPadButton, Object.assign({
|
|
29341
|
+
className: "left"
|
|
29342
|
+
}, buttonProps('left'))), React__default.createElement(DPadCenter, {
|
|
29242
29343
|
size: size,
|
|
29243
29344
|
disabled: disabled,
|
|
29244
29345
|
onContextMenu: preventDefault
|
|
29245
29346
|
}));
|
|
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
29347
|
});
|
|
29348
|
+
JoystickDPad.displayName = 'JoystickDPad';
|
|
29317
29349
|
|
|
29318
29350
|
var DropdownSelectorContainer = function DropdownSelectorContainer(_ref) {
|
|
29319
29351
|
var title = _ref.title,
|