@rpg-engine/long-bow 0.7.99 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.7.99",
3
+ "version": "0.8.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -28,6 +28,8 @@ interface IDPadOptions {
28
28
  interface IDPadProps {
29
29
  /** Callback fired when a direction is pressed */
30
30
  onDirectionPress?: (direction: 'up' | 'down' | 'left' | 'right') => void;
31
+ /** Callback fired when a direction is released */
32
+ onDirectionRelease?: (direction: 'up' | 'down' | 'left' | 'right') => void;
31
33
  /** Whether the component is disabled */
32
34
  disabled?: boolean;
33
35
  /** Additional options for customizing the D-pad */
@@ -179,6 +181,7 @@ const DPadContainer = memo(styled.div<IDPadContainerProps>`
179
181
  export const JoystickDPad = memo(
180
182
  ({
181
183
  onDirectionPress,
184
+ onDirectionRelease,
182
185
  disabled = false,
183
186
  options = {},
184
187
  }: IDPadProps): JSX.Element => {
@@ -209,11 +212,14 @@ export const JoystickDPad = memo(
209
212
  }, []);
210
213
 
211
214
  const clearAllPresses = useCallback(() => {
215
+ if (activeDirectionRef.current && onDirectionRelease) {
216
+ onDirectionRelease(activeDirectionRef.current);
217
+ }
212
218
  clearPressInterval();
213
219
  setPressedButtons(new Set());
214
220
  activeDirectionRef.current = null;
215
221
  isPressedRef.current = false;
216
- }, [clearPressInterval]);
222
+ }, [clearPressInterval, onDirectionRelease]);
217
223
 
218
224
  const handleDirectionPress = useCallback(
219
225
  (direction: 'up' | 'down' | 'left' | 'right') => {