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