@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
package/dist/long-bow.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect, Component, useRef, useCallback, useContext, createContext, useMemo, Fragment } from 'react';
|
|
1
|
+
import React, { useState, useEffect, Component, useRef, useCallback, useContext, createContext, useMemo, memo, Fragment } from 'react';
|
|
2
2
|
import styled, { css, keyframes } from 'styled-components';
|
|
3
3
|
import { BeatLoader } from 'react-spinners';
|
|
4
4
|
import { v4 } from 'uuid';
|
|
@@ -29077,7 +29077,78 @@ var EmptyState = /*#__PURE__*/styled.div.withConfig({
|
|
|
29077
29077
|
componentId: "sc-19q95ue-15"
|
|
29078
29078
|
})(["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);
|
|
29079
29079
|
|
|
29080
|
-
|
|
29080
|
+
// Memoize the styled components since they don't depend on props that change frequently
|
|
29081
|
+
var DPadButton = /*#__PURE__*/memo( /*#__PURE__*/styled.div.withConfig({
|
|
29082
|
+
displayName: "JoystickDPad__DPadButton",
|
|
29083
|
+
componentId: "sc-q1e3gk-0"
|
|
29084
|
+
})(["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) {
|
|
29085
|
+
return props.isPressed ? '#363636' : '#424242';
|
|
29086
|
+
}, function (props) {
|
|
29087
|
+
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)';
|
|
29088
|
+
}, function (props) {
|
|
29089
|
+
return props.disabled ? 'not-allowed' : 'pointer';
|
|
29090
|
+
}, function (props) {
|
|
29091
|
+
return !props.disabled && !props.isPressed ? 'brightness(1.1)' : 'none';
|
|
29092
|
+
}, function (props) {
|
|
29093
|
+
var _props$size;
|
|
29094
|
+
return ((_props$size = props.size) != null ? _props$size : 100) * 0.05;
|
|
29095
|
+
}, function (props) {
|
|
29096
|
+
return props.isPressed ? 0.7 : 1;
|
|
29097
|
+
}, function (props) {
|
|
29098
|
+
var _props$size2;
|
|
29099
|
+
return ((_props$size2 = props.size) != null ? _props$size2 : 100) * 0.3;
|
|
29100
|
+
}, function (props) {
|
|
29101
|
+
var _props$size3;
|
|
29102
|
+
return ((_props$size3 = props.size) != null ? _props$size3 : 100) * 0.4;
|
|
29103
|
+
}, function (props) {
|
|
29104
|
+
return props.isPressed ? 0.95 : 1;
|
|
29105
|
+
}, function (props) {
|
|
29106
|
+
var _props$size4;
|
|
29107
|
+
return ((_props$size4 = props.size) != null ? _props$size4 : 100) * 0.4;
|
|
29108
|
+
}, function (props) {
|
|
29109
|
+
var _props$size5;
|
|
29110
|
+
return ((_props$size5 = props.size) != null ? _props$size5 : 100) * 0.3;
|
|
29111
|
+
}, function (props) {
|
|
29112
|
+
return props.isPressed ? 0.95 : 1;
|
|
29113
|
+
}));
|
|
29114
|
+
var DPadCenter = /*#__PURE__*/memo( /*#__PURE__*/styled.div.withConfig({
|
|
29115
|
+
displayName: "JoystickDPad__DPadCenter",
|
|
29116
|
+
componentId: "sc-q1e3gk-1"
|
|
29117
|
+
})(["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) {
|
|
29118
|
+
var _props$size6;
|
|
29119
|
+
return ((_props$size6 = props.size) != null ? _props$size6 : 100) * 0.3;
|
|
29120
|
+
}, function (props) {
|
|
29121
|
+
var _props$size7;
|
|
29122
|
+
return ((_props$size7 = props.size) != null ? _props$size7 : 100) * 0.3;
|
|
29123
|
+
}, function (props) {
|
|
29124
|
+
return props.disabled ? 'not-allowed' : 'default';
|
|
29125
|
+
}, function (props) {
|
|
29126
|
+
var _props$size8;
|
|
29127
|
+
return ((_props$size8 = props.size) != null ? _props$size8 : 100) * 0.08;
|
|
29128
|
+
}, function (props) {
|
|
29129
|
+
var _props$size9;
|
|
29130
|
+
return ((_props$size9 = props.size) != null ? _props$size9 : 100) * 0.08;
|
|
29131
|
+
}));
|
|
29132
|
+
var DPadContainer = /*#__PURE__*/memo( /*#__PURE__*/styled.div.withConfig({
|
|
29133
|
+
displayName: "JoystickDPad__DPadContainer",
|
|
29134
|
+
componentId: "sc-q1e3gk-2"
|
|
29135
|
+
})(["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) {
|
|
29136
|
+
var _props$size10;
|
|
29137
|
+
return (_props$size10 = props.size) != null ? _props$size10 : 100;
|
|
29138
|
+
}, function (props) {
|
|
29139
|
+
var _props$size11;
|
|
29140
|
+
return (_props$size11 = props.size) != null ? _props$size11 : 100;
|
|
29141
|
+
}, function (props) {
|
|
29142
|
+
return props.showBackground ? '#b8b8b8' : 'transparent';
|
|
29143
|
+
}, function (props) {
|
|
29144
|
+
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';
|
|
29145
|
+
}, function (props) {
|
|
29146
|
+
var _props$opacity;
|
|
29147
|
+
return props.disabled ? 0.5 : (_props$opacity = props.opacity) != null ? _props$opacity : 1;
|
|
29148
|
+
}, function (props) {
|
|
29149
|
+
return props.disabled ? 'not-allowed' : 'default';
|
|
29150
|
+
}));
|
|
29151
|
+
var JoystickDPad = /*#__PURE__*/memo(function (_ref) {
|
|
29081
29152
|
var onDirectionPress = _ref.onDirectionPress,
|
|
29082
29153
|
_ref$disabled = _ref.disabled,
|
|
29083
29154
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
@@ -29091,222 +29162,179 @@ var JoystickDPad = function JoystickDPad(_ref) {
|
|
|
29091
29162
|
size = _options$size === void 0 ? 100 : _options$size,
|
|
29092
29163
|
_options$pressInterva = options.pressInterval,
|
|
29093
29164
|
pressInterval = _options$pressInterva === void 0 ? 500 : _options$pressInterva;
|
|
29165
|
+
// Use refs for values that don't need to trigger re-renders
|
|
29094
29166
|
var _useState = useState(new Set()),
|
|
29095
29167
|
pressedButtons = _useState[0],
|
|
29096
29168
|
setPressedButtons = _useState[1];
|
|
29097
29169
|
var intervalRef = useRef(null);
|
|
29098
29170
|
var activeDirectionRef = useRef(null);
|
|
29171
|
+
var touchStartRef = useRef(null);
|
|
29172
|
+
var isPressedRef = useRef(false);
|
|
29099
29173
|
var clearPressInterval = useCallback(function () {
|
|
29100
|
-
if (intervalRef.current) {
|
|
29174
|
+
if (intervalRef.current !== null) {
|
|
29101
29175
|
window.clearInterval(intervalRef.current);
|
|
29102
29176
|
intervalRef.current = null;
|
|
29103
29177
|
}
|
|
29104
29178
|
activeDirectionRef.current = null;
|
|
29105
29179
|
}, []);
|
|
29180
|
+
var clearAllPresses = useCallback(function () {
|
|
29181
|
+
clearPressInterval();
|
|
29182
|
+
setPressedButtons(new Set());
|
|
29183
|
+
activeDirectionRef.current = null;
|
|
29184
|
+
isPressedRef.current = false;
|
|
29185
|
+
}, [clearPressInterval]);
|
|
29106
29186
|
var handleDirectionPress = useCallback(function (direction) {
|
|
29107
29187
|
if (disabled) return;
|
|
29108
|
-
// Clear any existing
|
|
29109
|
-
|
|
29110
|
-
// Set
|
|
29188
|
+
// Clear any existing presses first
|
|
29189
|
+
clearAllPresses();
|
|
29190
|
+
// Set new direction
|
|
29111
29191
|
activeDirectionRef.current = direction;
|
|
29112
|
-
|
|
29113
|
-
|
|
29114
|
-
});
|
|
29115
|
-
// Trigger first press immediately
|
|
29192
|
+
isPressedRef.current = true;
|
|
29193
|
+
setPressedButtons(new Set([direction]));
|
|
29116
29194
|
onDirectionPress == null ? void 0 : onDirectionPress(direction);
|
|
29117
|
-
// Set up the interval for continuous press
|
|
29118
29195
|
intervalRef.current = window.setInterval(function () {
|
|
29119
29196
|
if (activeDirectionRef.current === direction) {
|
|
29120
29197
|
onDirectionPress == null ? void 0 : onDirectionPress(direction);
|
|
29198
|
+
} else {
|
|
29199
|
+
clearPressInterval();
|
|
29121
29200
|
}
|
|
29122
29201
|
}, pressInterval);
|
|
29123
|
-
}, [disabled, onDirectionPress, pressInterval, clearPressInterval]);
|
|
29202
|
+
}, [disabled, onDirectionPress, pressInterval, clearPressInterval, clearAllPresses]);
|
|
29124
29203
|
var handleDirectionRelease = useCallback(function (direction) {
|
|
29125
|
-
setPressedButtons(function (prev) {
|
|
29126
|
-
var next = new Set(prev);
|
|
29127
|
-
next["delete"](direction);
|
|
29128
|
-
return next;
|
|
29129
|
-
});
|
|
29130
29204
|
if (activeDirectionRef.current === direction) {
|
|
29131
|
-
|
|
29205
|
+
clearAllPresses();
|
|
29132
29206
|
}
|
|
29133
|
-
}, [
|
|
29134
|
-
|
|
29207
|
+
}, [clearAllPresses]);
|
|
29208
|
+
var handleTouchStart = useCallback(function (e, direction) {
|
|
29209
|
+
var touch = e.touches[0];
|
|
29210
|
+
if (touch) {
|
|
29211
|
+
touchStartRef.current = {
|
|
29212
|
+
x: touch.clientX,
|
|
29213
|
+
y: touch.clientY
|
|
29214
|
+
};
|
|
29215
|
+
handleDirectionPress(direction);
|
|
29216
|
+
}
|
|
29217
|
+
}, [handleDirectionPress]);
|
|
29218
|
+
var handleTouchMove = useCallback(function (e) {
|
|
29219
|
+
var touch = e.touches[0];
|
|
29220
|
+
if (!touch || !touchStartRef.current) return;
|
|
29221
|
+
var _touchStartRef$curren = touchStartRef.current,
|
|
29222
|
+
startX = _touchStartRef$curren.x,
|
|
29223
|
+
startY = _touchStartRef$curren.y;
|
|
29224
|
+
var deltaX = touch.clientX - startX;
|
|
29225
|
+
var deltaY = touch.clientY - startY;
|
|
29226
|
+
// Calculate angle and distance
|
|
29227
|
+
var distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
29228
|
+
var angle = Math.atan2(deltaY, deltaX) * (180 / Math.PI);
|
|
29229
|
+
// Only trigger if we've moved enough
|
|
29230
|
+
var threshold = size * 0.15; // Adaptive threshold based on d-pad size
|
|
29231
|
+
if (distance < threshold) return;
|
|
29232
|
+
var newDirection = null;
|
|
29233
|
+
// Determine direction based on angle
|
|
29234
|
+
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';
|
|
29235
|
+
if (newDirection && newDirection !== activeDirectionRef.current) {
|
|
29236
|
+
handleDirectionPress(newDirection);
|
|
29237
|
+
// Update touch start to current position to prevent jitter
|
|
29238
|
+
touchStartRef.current = {
|
|
29239
|
+
x: touch.clientX,
|
|
29240
|
+
y: touch.clientY
|
|
29241
|
+
};
|
|
29242
|
+
}
|
|
29243
|
+
}, [handleDirectionPress, size]);
|
|
29244
|
+
// Add a new cleanup function for touch events
|
|
29245
|
+
var cleanupTouchEvents = useCallback(function () {
|
|
29246
|
+
touchStartRef.current = null;
|
|
29247
|
+
if (activeDirectionRef.current) {
|
|
29248
|
+
handleDirectionRelease(activeDirectionRef.current);
|
|
29249
|
+
}
|
|
29250
|
+
}, [handleDirectionRelease]);
|
|
29251
|
+
// Enhance the touch end handler
|
|
29252
|
+
var handleTouchEnd = useCallback(function () {
|
|
29253
|
+
cleanupTouchEvents();
|
|
29254
|
+
}, [cleanupTouchEvents]);
|
|
29255
|
+
// Add touch cancel handler
|
|
29256
|
+
var handleTouchCancel = useCallback(function () {
|
|
29257
|
+
cleanupTouchEvents();
|
|
29258
|
+
}, [cleanupTouchEvents]);
|
|
29259
|
+
// Enhance cleanup effect
|
|
29135
29260
|
useEffect(function () {
|
|
29261
|
+
if (disabled) {
|
|
29262
|
+
clearAllPresses();
|
|
29263
|
+
}
|
|
29264
|
+
var handleBlur = function handleBlur() {
|
|
29265
|
+
clearAllPresses();
|
|
29266
|
+
};
|
|
29267
|
+
var handleVisibilityChange = function handleVisibilityChange() {
|
|
29268
|
+
if (document.hidden) {
|
|
29269
|
+
clearAllPresses();
|
|
29270
|
+
}
|
|
29271
|
+
};
|
|
29272
|
+
var handlePointerUp = function handlePointerUp() {
|
|
29273
|
+
// Global pointer up as fallback for stuck buttons
|
|
29274
|
+
if (isPressedRef.current) {
|
|
29275
|
+
clearAllPresses();
|
|
29276
|
+
}
|
|
29277
|
+
};
|
|
29278
|
+
window.addEventListener('blur', handleBlur);
|
|
29279
|
+
window.addEventListener('pointerup', handlePointerUp);
|
|
29280
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
29136
29281
|
return function () {
|
|
29137
|
-
|
|
29282
|
+
clearAllPresses();
|
|
29283
|
+
window.removeEventListener('blur', handleBlur);
|
|
29284
|
+
window.removeEventListener('pointerup', handlePointerUp);
|
|
29285
|
+
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
29138
29286
|
};
|
|
29139
|
-
}, [
|
|
29140
|
-
|
|
29287
|
+
}, [disabled, clearAllPresses]);
|
|
29288
|
+
// Memoize the preventDefault handler
|
|
29289
|
+
var preventDefault = useCallback(function (e) {
|
|
29141
29290
|
e.preventDefault();
|
|
29142
29291
|
e.stopPropagation();
|
|
29143
|
-
};
|
|
29292
|
+
}, []);
|
|
29293
|
+
// Memoize button props to prevent unnecessary re-renders
|
|
29294
|
+
var buttonProps = useCallback(function (direction) {
|
|
29295
|
+
return {
|
|
29296
|
+
onMouseDown: function onMouseDown() {
|
|
29297
|
+
return handleDirectionPress(direction);
|
|
29298
|
+
},
|
|
29299
|
+
onMouseUp: function onMouseUp() {
|
|
29300
|
+
return handleDirectionRelease(direction);
|
|
29301
|
+
},
|
|
29302
|
+
onMouseLeave: function onMouseLeave() {
|
|
29303
|
+
return handleDirectionRelease(direction);
|
|
29304
|
+
},
|
|
29305
|
+
onTouchStart: function onTouchStart(e) {
|
|
29306
|
+
return handleTouchStart(e, direction);
|
|
29307
|
+
},
|
|
29308
|
+
onTouchMove: handleTouchMove,
|
|
29309
|
+
onTouchEnd: handleTouchEnd,
|
|
29310
|
+
onContextMenu: preventDefault,
|
|
29311
|
+
size: size,
|
|
29312
|
+
isPressed: pressedButtons.has(direction),
|
|
29313
|
+
disabled: disabled
|
|
29314
|
+
};
|
|
29315
|
+
}, [handleDirectionPress, handleDirectionRelease, handleTouchStart, handleTouchMove, handleTouchEnd, preventDefault, size, pressedButtons, disabled]);
|
|
29144
29316
|
return React.createElement(DPadContainer, {
|
|
29145
29317
|
opacity: opacity,
|
|
29146
29318
|
showBackground: showBackground,
|
|
29147
29319
|
size: size,
|
|
29148
29320
|
disabled: disabled,
|
|
29149
|
-
onContextMenu: preventDefault
|
|
29150
|
-
}, React.createElement(DPadButton, {
|
|
29151
|
-
className: "up",
|
|
29152
|
-
onMouseDown: function onMouseDown() {
|
|
29153
|
-
return handleDirectionPress('up');
|
|
29154
|
-
},
|
|
29155
|
-
onMouseUp: function onMouseUp() {
|
|
29156
|
-
return handleDirectionRelease('up');
|
|
29157
|
-
},
|
|
29158
|
-
onMouseLeave: function onMouseLeave() {
|
|
29159
|
-
return handleDirectionRelease('up');
|
|
29160
|
-
},
|
|
29161
|
-
onTouchStart: function onTouchStart() {
|
|
29162
|
-
return handleDirectionPress('up');
|
|
29163
|
-
},
|
|
29164
|
-
onTouchEnd: function onTouchEnd() {
|
|
29165
|
-
return handleDirectionRelease('up');
|
|
29166
|
-
},
|
|
29167
29321
|
onContextMenu: preventDefault,
|
|
29168
|
-
|
|
29169
|
-
|
|
29170
|
-
|
|
29171
|
-
}), React.createElement(DPadButton, {
|
|
29172
|
-
className: "right"
|
|
29173
|
-
|
|
29174
|
-
|
|
29175
|
-
|
|
29176
|
-
|
|
29177
|
-
|
|
29178
|
-
},
|
|
29179
|
-
onMouseLeave: function onMouseLeave() {
|
|
29180
|
-
return handleDirectionRelease('right');
|
|
29181
|
-
},
|
|
29182
|
-
onTouchStart: function onTouchStart() {
|
|
29183
|
-
return handleDirectionPress('right');
|
|
29184
|
-
},
|
|
29185
|
-
onTouchEnd: function onTouchEnd() {
|
|
29186
|
-
return handleDirectionRelease('right');
|
|
29187
|
-
},
|
|
29188
|
-
onContextMenu: preventDefault,
|
|
29189
|
-
size: size,
|
|
29190
|
-
isPressed: pressedButtons.has('right'),
|
|
29191
|
-
disabled: disabled
|
|
29192
|
-
}), React.createElement(DPadButton, {
|
|
29193
|
-
className: "down",
|
|
29194
|
-
onMouseDown: function onMouseDown() {
|
|
29195
|
-
return handleDirectionPress('down');
|
|
29196
|
-
},
|
|
29197
|
-
onMouseUp: function onMouseUp() {
|
|
29198
|
-
return handleDirectionRelease('down');
|
|
29199
|
-
},
|
|
29200
|
-
onMouseLeave: function onMouseLeave() {
|
|
29201
|
-
return handleDirectionRelease('down');
|
|
29202
|
-
},
|
|
29203
|
-
onTouchStart: function onTouchStart() {
|
|
29204
|
-
return handleDirectionPress('down');
|
|
29205
|
-
},
|
|
29206
|
-
onTouchEnd: function onTouchEnd() {
|
|
29207
|
-
return handleDirectionRelease('down');
|
|
29208
|
-
},
|
|
29209
|
-
onContextMenu: preventDefault,
|
|
29210
|
-
size: size,
|
|
29211
|
-
isPressed: pressedButtons.has('down'),
|
|
29212
|
-
disabled: disabled
|
|
29213
|
-
}), React.createElement(DPadButton, {
|
|
29214
|
-
className: "left",
|
|
29215
|
-
onMouseDown: function onMouseDown() {
|
|
29216
|
-
return handleDirectionPress('left');
|
|
29217
|
-
},
|
|
29218
|
-
onMouseUp: function onMouseUp() {
|
|
29219
|
-
return handleDirectionRelease('left');
|
|
29220
|
-
},
|
|
29221
|
-
onMouseLeave: function onMouseLeave() {
|
|
29222
|
-
return handleDirectionRelease('left');
|
|
29223
|
-
},
|
|
29224
|
-
onTouchStart: function onTouchStart() {
|
|
29225
|
-
return handleDirectionPress('left');
|
|
29226
|
-
},
|
|
29227
|
-
onTouchEnd: function onTouchEnd() {
|
|
29228
|
-
return handleDirectionRelease('left');
|
|
29229
|
-
},
|
|
29230
|
-
onContextMenu: preventDefault,
|
|
29231
|
-
size: size,
|
|
29232
|
-
isPressed: pressedButtons.has('left'),
|
|
29233
|
-
disabled: disabled
|
|
29234
|
-
}), React.createElement(DPadCenter, {
|
|
29322
|
+
onTouchCancel: handleTouchCancel
|
|
29323
|
+
}, React.createElement(DPadButton, Object.assign({
|
|
29324
|
+
className: "up"
|
|
29325
|
+
}, buttonProps('up'))), React.createElement(DPadButton, Object.assign({
|
|
29326
|
+
className: "right"
|
|
29327
|
+
}, buttonProps('right'))), React.createElement(DPadButton, Object.assign({
|
|
29328
|
+
className: "down"
|
|
29329
|
+
}, buttonProps('down'))), React.createElement(DPadButton, Object.assign({
|
|
29330
|
+
className: "left"
|
|
29331
|
+
}, buttonProps('left'))), React.createElement(DPadCenter, {
|
|
29235
29332
|
size: size,
|
|
29236
29333
|
disabled: disabled,
|
|
29237
29334
|
onContextMenu: preventDefault
|
|
29238
29335
|
}));
|
|
29239
|
-
};
|
|
29240
|
-
var DPadContainer = /*#__PURE__*/styled.div.withConfig({
|
|
29241
|
-
displayName: "JoystickDPad__DPadContainer",
|
|
29242
|
-
componentId: "sc-q1e3gk-0"
|
|
29243
|
-
})(["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) {
|
|
29244
|
-
var _props$size;
|
|
29245
|
-
return (_props$size = props.size) != null ? _props$size : 100;
|
|
29246
|
-
}, function (props) {
|
|
29247
|
-
var _props$size2;
|
|
29248
|
-
return (_props$size2 = props.size) != null ? _props$size2 : 100;
|
|
29249
|
-
}, function (props) {
|
|
29250
|
-
return props.showBackground ? '#b8b8b8' : 'transparent';
|
|
29251
|
-
}, function (props) {
|
|
29252
|
-
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';
|
|
29253
|
-
}, function (props) {
|
|
29254
|
-
var _props$opacity;
|
|
29255
|
-
return props.disabled ? 0.5 : (_props$opacity = props.opacity) != null ? _props$opacity : 1;
|
|
29256
|
-
}, function (props) {
|
|
29257
|
-
return props.disabled ? 'not-allowed' : 'default';
|
|
29258
|
-
});
|
|
29259
|
-
var DPadButton = /*#__PURE__*/styled.div.withConfig({
|
|
29260
|
-
displayName: "JoystickDPad__DPadButton",
|
|
29261
|
-
componentId: "sc-q1e3gk-1"
|
|
29262
|
-
})(["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) {
|
|
29263
|
-
return props.isPressed ? '#363636' : '#424242';
|
|
29264
|
-
}, function (props) {
|
|
29265
|
-
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)';
|
|
29266
|
-
}, function (props) {
|
|
29267
|
-
return props.disabled ? 'not-allowed' : 'pointer';
|
|
29268
|
-
}, function (props) {
|
|
29269
|
-
return !props.disabled && !props.isPressed ? 'brightness(1.1)' : 'none';
|
|
29270
|
-
}, function (props) {
|
|
29271
|
-
var _props$size3;
|
|
29272
|
-
return ((_props$size3 = props.size) != null ? _props$size3 : 100) * 0.05;
|
|
29273
|
-
}, function (props) {
|
|
29274
|
-
return props.isPressed ? 0.7 : 1;
|
|
29275
|
-
}, function (props) {
|
|
29276
|
-
var _props$size4;
|
|
29277
|
-
return ((_props$size4 = props.size) != null ? _props$size4 : 100) * 0.3;
|
|
29278
|
-
}, function (props) {
|
|
29279
|
-
var _props$size5;
|
|
29280
|
-
return ((_props$size5 = props.size) != null ? _props$size5 : 100) * 0.4;
|
|
29281
|
-
}, function (props) {
|
|
29282
|
-
return props.isPressed ? 0.95 : 1;
|
|
29283
|
-
}, function (props) {
|
|
29284
|
-
var _props$size6;
|
|
29285
|
-
return ((_props$size6 = props.size) != null ? _props$size6 : 100) * 0.4;
|
|
29286
|
-
}, function (props) {
|
|
29287
|
-
var _props$size7;
|
|
29288
|
-
return ((_props$size7 = props.size) != null ? _props$size7 : 100) * 0.3;
|
|
29289
|
-
}, function (props) {
|
|
29290
|
-
return props.isPressed ? 0.95 : 1;
|
|
29291
|
-
});
|
|
29292
|
-
var DPadCenter = /*#__PURE__*/styled.div.withConfig({
|
|
29293
|
-
displayName: "JoystickDPad__DPadCenter",
|
|
29294
|
-
componentId: "sc-q1e3gk-2"
|
|
29295
|
-
})(["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) {
|
|
29296
|
-
var _props$size8;
|
|
29297
|
-
return ((_props$size8 = props.size) != null ? _props$size8 : 100) * 0.3;
|
|
29298
|
-
}, function (props) {
|
|
29299
|
-
var _props$size9;
|
|
29300
|
-
return ((_props$size9 = props.size) != null ? _props$size9 : 100) * 0.3;
|
|
29301
|
-
}, function (props) {
|
|
29302
|
-
return props.disabled ? 'not-allowed' : 'default';
|
|
29303
|
-
}, function (props) {
|
|
29304
|
-
var _props$size10;
|
|
29305
|
-
return ((_props$size10 = props.size) != null ? _props$size10 : 100) * 0.08;
|
|
29306
|
-
}, function (props) {
|
|
29307
|
-
var _props$size11;
|
|
29308
|
-
return ((_props$size11 = props.size) != null ? _props$size11 : 100) * 0.08;
|
|
29309
29336
|
});
|
|
29337
|
+
JoystickDPad.displayName = 'JoystickDPad';
|
|
29310
29338
|
|
|
29311
29339
|
var DropdownSelectorContainer = function DropdownSelectorContainer(_ref) {
|
|
29312
29340
|
var title = _ref.title,
|