react-simple-game-engine 0.2.87 → 0.2.89

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.
@@ -0,0 +1,12 @@
1
+ export declare type UseLongPressProps = {
2
+ onLongPress: () => void | undefined;
3
+ delay?: number;
4
+ exts?: {
5
+ onPress?: () => void | undefined;
6
+ };
7
+ };
8
+ export declare function useLongPress(onLongPress: UseLongPressProps["onLongPress"], delay?: UseLongPressProps["delay"], exts?: UseLongPressProps["exts"]): {
9
+ onMouseDown: () => void;
10
+ onMouseUp: () => void;
11
+ };
12
+ //# sourceMappingURL=interact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interact.d.ts","sourceRoot":"","sources":["../../src/hooks/interact.ts"],"names":[],"mappings":"AAEA,oBAAY,iBAAiB,GAAG;IAC9B,WAAW,EAAE,MAAM,IAAI,GAAG,SAAS,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,MAAM,IAAI,GAAG,SAAS,CAAC;KAClC,CAAC;CACH,CAAC;AAEF,wBAAgB,YAAY,CAC1B,WAAW,EAAE,iBAAiB,CAAC,aAAa,CAAC,EAC7C,KAAK,GAAE,iBAAiB,CAAC,OAAO,CAAO,EACvC,IAAI,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC;;;EAyBjC"}
@@ -0,0 +1,24 @@
1
+ import { useEffect, useMemo, useRef } from "react";
2
+ export function useLongPress(onLongPress, delay, exts) {
3
+ if (delay === void 0) { delay = 600; }
4
+ var onPress = (exts || {}).onPress;
5
+ var refTimer = useRef();
6
+ useEffect(function () {
7
+ return function () {
8
+ clearTimeout(refTimer.current);
9
+ };
10
+ }, []);
11
+ return useMemo(function () {
12
+ return {
13
+ onMouseDown: function () {
14
+ onPress === null || onPress === void 0 ? void 0 : onPress();
15
+ refTimer.current = setTimeout(function () {
16
+ onLongPress === null || onLongPress === void 0 ? void 0 : onLongPress();
17
+ }, delay);
18
+ },
19
+ onMouseUp: function () {
20
+ clearTimeout(refTimer.current);
21
+ },
22
+ };
23
+ }, [delay, onPress]);
24
+ }
@@ -1,4 +1,5 @@
1
1
  import { ReactNode } from "react";
2
+ import { UseLongPressProps } from "../hooks/interact";
2
3
  export declare type ControlProps = {
3
4
  top?: number;
4
5
  left?: number;
@@ -8,6 +9,8 @@ export declare type ControlProps = {
8
9
  xAxisOriginCenter?: boolean;
9
10
  yAxisOriginCenter?: boolean;
10
11
  orientation?: "vertical" | "horizontal";
12
+ alignment?: "flex-start" | "center" | "flex-end";
13
+ interact?: Partial<UseLongPressProps>;
11
14
  };
12
- export declare function Control({ xAxisOriginCenter, yAxisOriginCenter, top, left, right, bottom, children, orientation, }: ControlProps): JSX.Element;
15
+ export declare function Control({ xAxisOriginCenter, yAxisOriginCenter, top, left, right, bottom, children, orientation, alignment, interact, }: ControlProps): JSX.Element;
13
16
  //# sourceMappingURL=control.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/ui-components/control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AAE3C,oBAAY,YAAY,GAAG;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;CACzC,CAAC;AAEF,wBAAgB,OAAO,CAAC,EACtB,iBAAyB,EACzB,iBAAyB,EACzB,GAAG,EACH,IAAI,EACJ,KAAK,EACL,MAAM,EACN,QAAQ,EACR,WAAwB,GACzB,EAAE,YAAY,eAuBd"}
1
+ {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/ui-components/control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAgB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEpE,oBAAY,YAAY,GAAG;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IACxC,SAAS,CAAC,EAAE,YAAY,GAAG,QAAQ,GAAG,UAAU,CAAC;IAEjD,QAAQ,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACvC,CAAC;AAEF,wBAAgB,OAAO,CAAC,EACtB,iBAAyB,EACzB,iBAAyB,EACzB,GAAG,EACH,IAAI,EACJ,KAAK,EACL,MAAM,EACN,QAAQ,EACR,WAAwB,EACxB,SAAwB,EACxB,QAAa,GACd,EAAE,YAAY,eA8Bd"}
@@ -11,8 +11,10 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { useMemo } from "react";
14
+ import { useLongPress } from "../hooks/interact";
14
15
  export function Control(_a) {
15
- var _b = _a.xAxisOriginCenter, xAxisOriginCenter = _b === void 0 ? false : _b, _c = _a.yAxisOriginCenter, yAxisOriginCenter = _c === void 0 ? false : _c, top = _a.top, left = _a.left, right = _a.right, bottom = _a.bottom, children = _a.children, _d = _a.orientation, orientation = _d === void 0 ? "vertical" : _d;
16
+ var _b = _a.xAxisOriginCenter, xAxisOriginCenter = _b === void 0 ? false : _b, _c = _a.yAxisOriginCenter, yAxisOriginCenter = _c === void 0 ? false : _c, top = _a.top, left = _a.left, right = _a.right, bottom = _a.bottom, children = _a.children, _d = _a.orientation, orientation = _d === void 0 ? "vertical" : _d, _e = _a.alignment, alignment = _e === void 0 ? "flex-start" : _e, _f = _a.interact, interact = _f === void 0 ? {} : _f;
17
+ var longPressProps = useLongPress(interact.onLongPress, interact.delay, interact.exts);
16
18
  var transform = useMemo(function () {
17
19
  var x = xAxisOriginCenter ? "".concat(left != null ? -50 : 50, "%") : 0;
18
20
  var y = yAxisOriginCenter ? "".concat(top != null ? -50 : 50, "%") : 0;
@@ -26,6 +28,7 @@ export function Control(_a) {
26
28
  bottom: bottom,
27
29
  display: "inline-flex",
28
30
  flexDirection: orientation === "vertical" ? "column" : "row",
31
+ alignItems: alignment,
29
32
  transform: transform,
30
- } }, { children: children })));
33
+ } }, longPressProps, { children: children })));
31
34
  }
@@ -3,4 +3,5 @@ export * from "./classes/sound-watcher";
3
3
  export * from "./ui-components/modal";
4
4
  export * from "./ui-components/control";
5
5
  export * from "./ui-components/control-container";
6
+ export * from "./hooks/interact";
6
7
  //# sourceMappingURL=utilities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC"}
1
+ {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,kBAAkB,CAAC"}
package/lib/utilities.js CHANGED
@@ -3,3 +3,4 @@ export * from "./classes/sound-watcher";
3
3
  export * from "./ui-components/modal";
4
4
  export * from "./ui-components/control";
5
5
  export * from "./ui-components/control-container";
6
+ export * from "./hooks/interact";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-simple-game-engine",
3
- "version": "0.2.87",
3
+ "version": "0.2.89",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib",