@gamepark/react-game 7.3.0 → 7.4.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/GameProvider/GameProvider.js +1 -3
- package/dist/components/GameProvider/GameProvider.js.map +1 -1
- package/dist/components/Header/HeaderText.d.ts +6 -1
- package/dist/components/Header/HeaderText.js +14 -5
- package/dist/components/Header/HeaderText.js.map +1 -1
- package/dist/components/JournalTabs/JournalTabs.js +1 -1
- package/dist/components/JournalTabs/JournalTabs.js.map +1 -1
- package/dist/components/LoadingScreen/LoadingScreen.js +5 -0
- package/dist/components/LoadingScreen/LoadingScreen.js.map +1 -1
- package/dist/components/material/DraggableMaterial.d.ts +12 -2
- package/dist/components/material/DraggableMaterial.js +50 -57
- package/dist/components/material/DraggableMaterial.js.map +1 -1
- package/dist/components/material/GameTable/DynamicItemsDisplay.js +52 -8
- package/dist/components/material/GameTable/DynamicItemsDisplay.js.map +1 -1
- package/dist/components/material/GameTable/GameMaterialDisplay.js +5 -2
- package/dist/components/material/GameTable/GameMaterialDisplay.js.map +1 -1
- package/dist/components/material/GameTable/GameTable.d.ts +1 -0
- package/dist/components/material/GameTable/GameTable.js +49 -18
- package/dist/components/material/GameTable/GameTable.js.map +1 -1
- package/dist/components/material/GameTable/GameTableNavigation.js +7 -0
- package/dist/components/material/GameTable/GameTableNavigation.js.map +1 -1
- package/dist/components/material/GameTable/ItemDisplay.js +4 -4
- package/dist/components/material/GameTable/ItemDisplay.js.map +1 -1
- package/dist/components/material/GameTable/StaticItemsDisplay.js +21 -6
- package/dist/components/material/GameTable/StaticItemsDisplay.js.map +1 -1
- package/dist/components/material/GameTable/focus/FocusProvider.js +11 -5
- package/dist/components/material/GameTable/focus/FocusProvider.js.map +1 -1
- package/dist/components/material/GameTable/focus/NoZoomFocusProvider.js +2 -2
- package/dist/components/material/GameTable/focus/NoZoomFocusProvider.js.map +1 -1
- package/dist/components/material/GameTable/focus/index.d.ts +1 -0
- package/dist/components/material/GameTable/focus/index.js +1 -0
- package/dist/components/material/GameTable/focus/index.js.map +1 -1
- package/dist/components/material/GameTable/index.d.ts +2 -0
- package/dist/components/material/GameTable/index.js +2 -0
- package/dist/components/material/GameTable/index.js.map +1 -1
- package/dist/components/material/MaterialDescription.d.ts +9 -1
- package/dist/components/material/MaterialDescription.js +20 -13
- package/dist/components/material/MaterialDescription.js.map +1 -1
- package/dist/components/material/animations/AnimationBuilder.d.ts +160 -0
- package/dist/components/material/animations/AnimationBuilder.js +287 -0
- package/dist/components/material/animations/AnimationBuilder.js.map +1 -0
- package/dist/components/material/animations/CreateItemAnimations.d.ts +4 -2
- package/dist/components/material/animations/CreateItemAnimations.js +80 -10
- package/dist/components/material/animations/CreateItemAnimations.js.map +1 -1
- package/dist/components/material/animations/DeleteItemAnimations.d.ts +3 -1
- package/dist/components/material/animations/DeleteItemAnimations.js +16 -4
- package/dist/components/material/animations/DeleteItemAnimations.js.map +1 -1
- package/dist/components/material/animations/DeleteItemAtOnceAnimations.d.ts +3 -1
- package/dist/components/material/animations/DeleteItemAtOnceAnimations.js +16 -4
- package/dist/components/material/animations/DeleteItemAtOnceAnimations.js.map +1 -1
- package/dist/components/material/animations/ItemAnimations.d.ts +35 -1
- package/dist/components/material/animations/ItemAnimations.js +143 -1
- package/dist/components/material/animations/ItemAnimations.js.map +1 -1
- package/dist/components/material/animations/MaterialAnimations.d.ts +2 -1
- package/dist/components/material/animations/MaterialAnimations.js +6 -6
- package/dist/components/material/animations/MaterialAnimations.js.map +1 -1
- package/dist/components/material/animations/MaterialGameAnimations.d.ts +94 -1
- package/dist/components/material/animations/MaterialGameAnimations.js +150 -2
- package/dist/components/material/animations/MaterialGameAnimations.js.map +1 -1
- package/dist/components/material/animations/MoveItemAnimations.d.ts +3 -1
- package/dist/components/material/animations/MoveItemAnimations.js +29 -5
- package/dist/components/material/animations/MoveItemAnimations.js.map +1 -1
- package/dist/components/material/animations/MoveItemAtOnceAnimations.d.ts +5 -2
- package/dist/components/material/animations/MoveItemAtOnceAnimations.js +45 -3
- package/dist/components/material/animations/MoveItemAtOnceAnimations.js.map +1 -1
- package/dist/components/material/animations/Trajectory.d.ts +132 -0
- package/dist/components/material/animations/Trajectory.js +87 -0
- package/dist/components/material/animations/Trajectory.js.map +1 -0
- package/dist/components/material/animations/index.d.ts +3 -0
- package/dist/components/material/animations/index.js +3 -0
- package/dist/components/material/animations/index.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useLegalMoves.js +2 -1
- package/dist/hooks/useLegalMoves.js.map +1 -1
- package/dist/hooks/useMaterialContextRef.d.ts +10 -0
- package/dist/hooks/useMaterialContextRef.js +12 -0
- package/dist/hooks/useMaterialContextRef.js.map +1 -0
- package/dist/hooks/usePlayerName.js +1 -1
- package/dist/hooks/usePlayerName.js.map +1 -1
- package/dist/hooks/useUndo.js +12 -3
- package/dist/hooks/useUndo.js.map +1 -1
- package/dist/locators/DeckLocator.d.ts +3 -1
- package/dist/locators/DeckLocator.js +6 -0
- package/dist/locators/DeckLocator.js.map +1 -1
- package/dist/locators/HandLocator.d.ts +1 -0
- package/dist/locators/HandLocator.js +3 -0
- package/dist/locators/HandLocator.js.map +1 -1
- package/dist/locators/ListLocator.d.ts +1 -0
- package/dist/locators/ListLocator.js +3 -0
- package/dist/locators/ListLocator.js.map +1 -1
- package/dist/locators/Locator.d.ts +39 -0
- package/dist/locators/Locator.js +74 -1
- package/dist/locators/Locator.js.map +1 -1
- package/dist/locators/PileLocator.d.ts +1 -0
- package/dist/locators/PileLocator.js +3 -0
- package/dist/locators/PileLocator.js.map +1 -1
- package/dist/utilities/translation.util.js +1 -1
- package/dist/utilities/translation.util.js.map +1 -1
- package/package.json +79 -77
|
@@ -8,10 +8,12 @@ import { transformItem } from './transformItem.util';
|
|
|
8
8
|
export class DeleteItemAnimations extends ItemAnimations {
|
|
9
9
|
duration;
|
|
10
10
|
droppedItemDuration;
|
|
11
|
-
|
|
11
|
+
trajectory;
|
|
12
|
+
constructor(duration = 1, droppedItemDuration = 0.2, trajectory) {
|
|
12
13
|
super();
|
|
13
14
|
this.duration = duration;
|
|
14
15
|
this.droppedItemDuration = droppedItemDuration;
|
|
16
|
+
this.trajectory = trajectory;
|
|
15
17
|
}
|
|
16
18
|
getPreDuration(move, context) {
|
|
17
19
|
const potentialDroppedItem = { type: move.itemType, index: move.itemIndex };
|
|
@@ -40,9 +42,19 @@ export class DeleteItemAnimations extends ItemAnimations {
|
|
|
40
42
|
if (currentOrigin.y !== futureOrigin.y) {
|
|
41
43
|
targetTransforms.unshift(`translateY(${getOriginDeltaPosition(boundaries.yMin, boundaries.yMax, futureOrigin.y, currentOrigin.y)}em)`);
|
|
42
44
|
}
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
45
|
+
// Check if trajectory is configured
|
|
46
|
+
const contextWithTrajectory = context;
|
|
47
|
+
const trajectory = this.trajectory ?? contextWithTrajectory.trajectory;
|
|
48
|
+
if (trajectory) {
|
|
49
|
+
const trajectoryContext = { ...context, trajectory };
|
|
50
|
+
const animationKeyframes = this.getTrajectoryKeyframes(originTransforms, targetTransforms, animation, trajectoryContext);
|
|
51
|
+
return this.getAnimationCssWithTrajectory(animationKeyframes, animation.duration, trajectory.easing, trajectory.elevation);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const animationKeyframes = this.getTransformKeyframes(originTransforms.join(' '), targetTransforms.join(' '), animation, context);
|
|
55
|
+
const description = context.material[context.type];
|
|
56
|
+
return description?.getAnimationCss(animationKeyframes, animation.duration);
|
|
57
|
+
}
|
|
46
58
|
}
|
|
47
59
|
else {
|
|
48
60
|
const fadeout = keyframes `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeleteItemAnimations.js","sourceRoot":"","sources":["../../../../src/components/material/animations/DeleteItemAnimations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,E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A;gBAClD,OAAO,WAAW,EAAE,eAAe,CAAC,kBAAkB,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAA;YAC7E,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,OAAO,GAAG,SAAS,CAAA;;;;OAIxB,CAAA;YACD,OAAO,GAAG,CAAA,cAAc,OAAO,IAAI,SAAS,CAAC,QAAQ,wBAAwB,CAAA;QAC/E,CAAC;IACH,CAAC;IAES,yBAAyB,CAAC,WAAmB,EAAE,UAAwC,EAAE,QAA8B;QAC/H,OAAO,SAAS,CAAA;;qBAEC,WAAW;;KAE3B,CAAA;IACH,CAAC;CACF"}
|
|
@@ -3,9 +3,11 @@ import { Animation } from '@gamepark/react-client';
|
|
|
3
3
|
import { DeleteItemsAtOnce } from '@gamepark/rules-api';
|
|
4
4
|
import { ItemContext } from '../../../locators';
|
|
5
5
|
import { ItemAnimations } from './ItemAnimations';
|
|
6
|
+
import { Trajectory } from './Trajectory';
|
|
6
7
|
export declare class DeleteItemAtOnceAnimations<P extends number = number, M extends number = number, L extends number = number> extends ItemAnimations<P, M, L> {
|
|
7
8
|
protected duration: number;
|
|
8
|
-
|
|
9
|
+
protected trajectory?: Trajectory<P, M, L> | undefined;
|
|
10
|
+
constructor(duration?: number, trajectory?: Trajectory<P, M, L> | undefined);
|
|
9
11
|
getPreDuration(): number;
|
|
10
12
|
getItemAnimation(context: ItemContext<P, M, L>, animation: Animation<DeleteItemsAtOnce<M>>): Interpolation<Theme>;
|
|
11
13
|
getMovedItemAnimation(context: ItemContext<P, M, L>, animation: Animation<DeleteItemsAtOnce<M>>): Interpolation<Theme>;
|
|
@@ -5,9 +5,11 @@ import { toClosestRotations, toSingleRotation } from './rotations.utils';
|
|
|
5
5
|
import { transformItem } from './transformItem.util';
|
|
6
6
|
export class DeleteItemAtOnceAnimations extends ItemAnimations {
|
|
7
7
|
duration;
|
|
8
|
-
|
|
8
|
+
trajectory;
|
|
9
|
+
constructor(duration = 1, trajectory) {
|
|
9
10
|
super();
|
|
10
11
|
this.duration = duration;
|
|
12
|
+
this.trajectory = trajectory;
|
|
11
13
|
}
|
|
12
14
|
getPreDuration() {
|
|
13
15
|
return this.duration;
|
|
@@ -23,9 +25,19 @@ export class DeleteItemAtOnceAnimations extends ItemAnimations {
|
|
|
23
25
|
const originTransforms = toSingleRotation(transformItem(context));
|
|
24
26
|
const targetTransforms = toSingleRotation(stockTransforms);
|
|
25
27
|
toClosestRotations(originTransforms, targetTransforms);
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
28
|
+
// Check if trajectory is configured
|
|
29
|
+
const contextWithTrajectory = context;
|
|
30
|
+
const trajectory = this.trajectory ?? contextWithTrajectory.trajectory;
|
|
31
|
+
if (trajectory) {
|
|
32
|
+
const trajectoryContext = { ...context, trajectory };
|
|
33
|
+
const animationKeyframes = this.getTrajectoryKeyframes(originTransforms, targetTransforms, animation, trajectoryContext);
|
|
34
|
+
return this.getAnimationCssWithTrajectory(animationKeyframes, animation.duration, trajectory.easing, trajectory.elevation);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const animationKeyframes = this.getTransformKeyframes(originTransforms.join(' '), targetTransforms.join(' '), animation, context);
|
|
38
|
+
const description = context.material[context.type];
|
|
39
|
+
return description?.getAnimationCss(animationKeyframes, animation.duration);
|
|
40
|
+
}
|
|
29
41
|
}
|
|
30
42
|
else {
|
|
31
43
|
const fadeout = keyframes `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeleteItemAtOnceAnimations.js","sourceRoot":"","sources":["../../../../src/components/material/animations/DeleteItemAtOnceAnimations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAiB,SAAS,EAAS,MAAM,gBAAgB,CAAA;AAIrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAA;AAChF,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"DeleteItemAtOnceAnimations.js","sourceRoot":"","sources":["../../../../src/components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C,MAAM,qBAAqB,GAAG,OAA6C,CAAA;YAC3E,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,qBAAqB,CAAC,UAAU,CAAA;YAEtE,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,iBAAiB,GAAuC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,CAAA;gBACxF,MAAM,kBAAkB,GAAG,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAA;gBACxH,OAAO,IAAI,CAAC,6BAA6B,CAAC,kBAAkB,EAAE,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;YAC5H,CAAC;iBAAM,CAAC;gBACN,MAAM,kBAAkB,GAAG,IAAI,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;gBACjI,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gBAClD,OAAO,WAAW,EAAE,eAAe,CAAC,kBAAkB,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAA;YAC7E,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,OAAO,GAAG,SAAS,CAAA;;;;OAIxB,CAAA;YACD,OAAO,GAAG,CAAA,cAAc,OAAO,IAAI,SAAS,CAAC,QAAQ,wBAAwB,CAAA;QAC/E,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,16 +1,50 @@
|
|
|
1
|
-
import { Interpolation, Theme } from '@emotion/react';
|
|
1
|
+
import { Interpolation, keyframes, Theme } from '@emotion/react';
|
|
2
2
|
import { Animation, Animations } from '@gamepark/react-client';
|
|
3
3
|
import { DisplayedItem, GridBoundaries, ItemMove, MaterialGame, MaterialMove } from '@gamepark/rules-api';
|
|
4
4
|
import { ItemContext, MaterialContext } from '../../../locators';
|
|
5
5
|
import { MaterialGameAnimationContext } from './MaterialGameAnimations';
|
|
6
|
+
import { ElevationConfig, Trajectory } from './Trajectory';
|
|
7
|
+
/**
|
|
8
|
+
* Extended ItemContext that includes trajectory configuration.
|
|
9
|
+
*/
|
|
10
|
+
export type ItemContextWithTrajectory<P extends number = number, M extends number = number, L extends number = number> = ItemContext<P, M, L> & {
|
|
11
|
+
trajectory?: Trajectory<P, M, L>;
|
|
12
|
+
};
|
|
6
13
|
export declare class ItemAnimations<P extends number = number, M extends number = number, L extends number = number> extends Animations<MaterialGame<P, M, L>, MaterialMove<P, M, L>, P> {
|
|
7
14
|
getItemAnimation(_context: ItemContext<P, M, L>, _animation: Animation<MaterialMove<P, M, L>>, _boundaries: GridBoundaries): Interpolation<Theme>;
|
|
8
15
|
getMaterialContext({ Rules, game, material, locators, playerId }: MaterialGameAnimationContext<P, M, L>): MaterialContext<P, M, L>;
|
|
9
16
|
getItemContext(context: MaterialGameAnimationContext<P, M, L>, item: Omit<DisplayedItem<M>, 'displayIndex'>): Omit<ItemContext<P, M, L>, 'displayIndex'>;
|
|
17
|
+
/**
|
|
18
|
+
* Generate simple from/to keyframes (legacy method).
|
|
19
|
+
*/
|
|
10
20
|
protected getTransformKeyframes(origin: string, destination: string, _animation: Animation<ItemMove<P, M, L>>, _context: ItemContext<P, M, L>): {
|
|
11
21
|
name: string;
|
|
12
22
|
styles: string;
|
|
13
23
|
anim: 1;
|
|
14
24
|
toString: () => string;
|
|
15
25
|
} & string;
|
|
26
|
+
/**
|
|
27
|
+
* Generate keyframes with integrated elevation and optional waypoints.
|
|
28
|
+
* The elevation is prepended to the transform chain so it operates in world coordinates.
|
|
29
|
+
*
|
|
30
|
+
* @param originTransforms Array of CSS transforms for the starting position
|
|
31
|
+
* @param targetTransforms Array of CSS transforms for the ending position
|
|
32
|
+
* @param animation The animation context
|
|
33
|
+
* @param context The item context (may include trajectory configuration)
|
|
34
|
+
*/
|
|
35
|
+
protected getTrajectoryKeyframes(originTransforms: string[], targetTransforms: string[], animation: Animation<ItemMove<P, M, L>>, context: ItemContextWithTrajectory<P, M, L>): {
|
|
36
|
+
name: string;
|
|
37
|
+
styles: string;
|
|
38
|
+
anim: 1;
|
|
39
|
+
toString: () => string;
|
|
40
|
+
} & string;
|
|
41
|
+
/**
|
|
42
|
+
* Generate animation CSS with elevation on the parent div and position on the child div.
|
|
43
|
+
*
|
|
44
|
+
* @param animationKeyframes The generated keyframes for position (child div)
|
|
45
|
+
* @param duration Animation duration in seconds
|
|
46
|
+
* @param easing CSS easing function
|
|
47
|
+
* @param elevationConfig Elevation configuration for the parent div arc
|
|
48
|
+
*/
|
|
49
|
+
protected getAnimationCssWithTrajectory(animationKeyframes: ReturnType<typeof keyframes>, duration: number, easing?: string, elevationConfig?: ElevationConfig | false): Interpolation<Theme>;
|
|
16
50
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { keyframes } from '@emotion/react';
|
|
1
|
+
import { css, keyframes } from '@emotion/react';
|
|
2
2
|
import { Animations } from '@gamepark/react-client';
|
|
3
|
+
import { getItemFromContext } from '../../../locators';
|
|
4
|
+
import { defaultElevation, extractTranslation, getElevationKeyframes, interpolateCoordinate } from './Trajectory';
|
|
3
5
|
export class ItemAnimations extends Animations {
|
|
4
6
|
getItemAnimation(_context, _animation, _boundaries) {
|
|
5
7
|
return;
|
|
@@ -10,6 +12,9 @@ export class ItemAnimations extends Animations {
|
|
|
10
12
|
getItemContext(context, item) {
|
|
11
13
|
return { ...this.getMaterialContext(context), ...item };
|
|
12
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Generate simple from/to keyframes (legacy method).
|
|
17
|
+
*/
|
|
13
18
|
getTransformKeyframes(origin, destination, _animation, _context) {
|
|
14
19
|
return keyframes `
|
|
15
20
|
from {
|
|
@@ -20,5 +25,142 @@ export class ItemAnimations extends Animations {
|
|
|
20
25
|
}
|
|
21
26
|
`;
|
|
22
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Generate keyframes with integrated elevation and optional waypoints.
|
|
30
|
+
* The elevation is prepended to the transform chain so it operates in world coordinates.
|
|
31
|
+
*
|
|
32
|
+
* @param originTransforms Array of CSS transforms for the starting position
|
|
33
|
+
* @param targetTransforms Array of CSS transforms for the ending position
|
|
34
|
+
* @param animation The animation context
|
|
35
|
+
* @param context The item context (may include trajectory configuration)
|
|
36
|
+
*/
|
|
37
|
+
getTrajectoryKeyframes(originTransforms, targetTransforms, animation, context) {
|
|
38
|
+
const waypoints = context.trajectory?.waypoints ?? [];
|
|
39
|
+
// If no waypoints, use simple keyframes
|
|
40
|
+
if (waypoints.length === 0) {
|
|
41
|
+
return this.getTransformKeyframes(originTransforms.join(' '), targetTransforms.join(' '), animation, context);
|
|
42
|
+
}
|
|
43
|
+
// Collect all time points
|
|
44
|
+
const timePoints = new Set([0, 1]);
|
|
45
|
+
// Add waypoint times
|
|
46
|
+
waypoints.forEach(w => timePoints.add(w.at));
|
|
47
|
+
const sortedTimes = [...timePoints].sort((a, b) => a - b);
|
|
48
|
+
// Extract coordinates for interpolation
|
|
49
|
+
const originCoords = extractTranslation(originTransforms);
|
|
50
|
+
const targetCoords = extractTranslation(targetTransforms);
|
|
51
|
+
// Build keyframes
|
|
52
|
+
const frames = [];
|
|
53
|
+
for (const t of sortedTimes) {
|
|
54
|
+
// Find if there's a waypoint at this time
|
|
55
|
+
const waypoint = waypoints.find(w => Math.abs(w.at - t) < 0.001);
|
|
56
|
+
// Calculate base interpolated position
|
|
57
|
+
let x = interpolateCoordinate(originCoords.x, targetCoords.x, t);
|
|
58
|
+
let y = interpolateCoordinate(originCoords.y, targetCoords.y, t);
|
|
59
|
+
let z = interpolateCoordinate(originCoords.z, targetCoords.z, t);
|
|
60
|
+
// Apply waypoint modifications
|
|
61
|
+
if (waypoint) {
|
|
62
|
+
if (waypoint.offset) {
|
|
63
|
+
x += waypoint.offset.x ?? 0;
|
|
64
|
+
y += waypoint.offset.y ?? 0;
|
|
65
|
+
z += waypoint.offset.z ?? 0;
|
|
66
|
+
}
|
|
67
|
+
if (waypoint.coordinates) {
|
|
68
|
+
x = waypoint.coordinates.x ?? x;
|
|
69
|
+
y = waypoint.coordinates.y ?? y;
|
|
70
|
+
z = waypoint.coordinates.z ?? z;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Build transform string
|
|
74
|
+
const transforms = [];
|
|
75
|
+
// Handle locator waypoints: use full transforms from the locator
|
|
76
|
+
if (waypoint?.locator !== undefined) {
|
|
77
|
+
const locator = waypoint.locator;
|
|
78
|
+
const resolvedLocation = typeof waypoint.location === 'function'
|
|
79
|
+
? waypoint.location(getItemFromContext(context))
|
|
80
|
+
: waypoint.location;
|
|
81
|
+
const location = { ...resolvedLocation };
|
|
82
|
+
const fakeItem = { location };
|
|
83
|
+
const locatorTransforms = locator.placeItem(fakeItem, context);
|
|
84
|
+
transforms.push('translate(-50%, -50%)');
|
|
85
|
+
transforms.push(...locatorTransforms);
|
|
86
|
+
}
|
|
87
|
+
else if (t === 0 && !waypoint) {
|
|
88
|
+
transforms.push(...originTransforms);
|
|
89
|
+
}
|
|
90
|
+
else if (t === 1 && !waypoint) {
|
|
91
|
+
transforms.push(...targetTransforms);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
// Build interpolated transforms
|
|
95
|
+
transforms.push('translate(-50%, -50%)');
|
|
96
|
+
transforms.push(`translate3d(${x}em, ${y}em, ${z}em)`);
|
|
97
|
+
// Interpolate rotation if present
|
|
98
|
+
const originRotation = extractRotation(originTransforms);
|
|
99
|
+
const targetRotation = extractRotation(targetTransforms);
|
|
100
|
+
if (originRotation !== undefined || targetRotation !== undefined) {
|
|
101
|
+
const rotation = interpolateCoordinate(originRotation ?? 0, targetRotation ?? 0, t);
|
|
102
|
+
if (rotation !== 0) {
|
|
103
|
+
transforms.push(`rotateZ(${rotation}deg)`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const percent = Math.round(t * 100);
|
|
108
|
+
const transformString = transforms.join(' ');
|
|
109
|
+
// Add easing for this segment if specified in waypoint
|
|
110
|
+
const easing = waypoint?.easing;
|
|
111
|
+
if (easing && t < 1) {
|
|
112
|
+
frames.push(`${percent}% { transform: ${transformString}; animation-timing-function: ${easing}; }`);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
frames.push(`${percent}% { transform: ${transformString}; }`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return keyframes `${frames.join('\n')}`;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Generate animation CSS with elevation on the parent div and position on the child div.
|
|
122
|
+
*
|
|
123
|
+
* @param animationKeyframes The generated keyframes for position (child div)
|
|
124
|
+
* @param duration Animation duration in seconds
|
|
125
|
+
* @param easing CSS easing function
|
|
126
|
+
* @param elevationConfig Elevation configuration for the parent div arc
|
|
127
|
+
*/
|
|
128
|
+
getAnimationCssWithTrajectory(animationKeyframes, duration, easing = 'ease-in-out', elevationConfig) {
|
|
129
|
+
if (elevationConfig !== false) {
|
|
130
|
+
const resolvedElevation = elevationConfig ?? defaultElevation;
|
|
131
|
+
const elevationArc = getElevationKeyframes(resolvedElevation);
|
|
132
|
+
return css `
|
|
133
|
+
animation: ${elevationArc} ${duration}s ease-in-out forwards;
|
|
134
|
+
> * {
|
|
135
|
+
animation: ${animationKeyframes} ${duration}s ${easing} forwards;
|
|
136
|
+
}
|
|
137
|
+
`;
|
|
138
|
+
}
|
|
139
|
+
return css `
|
|
140
|
+
> * {
|
|
141
|
+
animation: ${animationKeyframes} ${duration}s ${easing} forwards;
|
|
142
|
+
}
|
|
143
|
+
`;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Extract rotation value from transform array.
|
|
148
|
+
* @param transforms Array of CSS transform strings
|
|
149
|
+
* @returns Rotation in degrees, or undefined if no rotation found
|
|
150
|
+
*/
|
|
151
|
+
function extractRotation(transforms) {
|
|
152
|
+
for (const transform of transforms) {
|
|
153
|
+
const rotateZMatch = transform.match(/rotateZ\(\s*([-\d.]+)(deg|rad|turn)?\s*\)/);
|
|
154
|
+
if (rotateZMatch) {
|
|
155
|
+
const value = parseFloat(rotateZMatch[1]);
|
|
156
|
+
const unit = rotateZMatch[2] || 'deg';
|
|
157
|
+
if (unit === 'rad')
|
|
158
|
+
return value * (180 / Math.PI);
|
|
159
|
+
if (unit === 'turn')
|
|
160
|
+
return value * 360;
|
|
161
|
+
return value;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return undefined;
|
|
23
165
|
}
|
|
24
166
|
//# sourceMappingURL=ItemAnimations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemAnimations.js","sourceRoot":"","sources":["../../../../src/components/material/animations/ItemAnimations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAS,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"ItemAnimations.js","sourceRoot":"","sources":["../../../../src/components/material/animations/ItemAnimations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAiB,SAAS,EAAS,MAAM,gBAAgB,CAAA;AACrE,OAAO,EAAa,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAE9D,OAAO,EAAE,kBAAkB,EAAgC,MAAM,mBAAmB,CAAA;AAEpF,OAAO,EAAE,gBAAgB,EAAmB,kBAAkB,EAAE,qBAAqB,EAAE,qBAAqB,EAAc,MAAM,cAAc,CAAA;AAQ9I,MAAM,OAAO,cACX,SAAQ,UAA2D;IAEnE,gBAAgB,CAAC,QAA8B,EAAE,UAA4C,EAAE,WAA2B;QACxH,OAAM;IACR,CAAC;IAED,kBAAkB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAyC;QACrG,OAAO,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,IA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A;YAC7D,OAAO,GAAG,CAAA;qBACK,YAAY,IAAI,QAAQ;;uBAEtB,kBAAkB,IAAI,QAAQ,KAAK,MAAM;;OAEzD,CAAA;QACH,CAAC;QACD,OAAO,GAAG,CAAA;;qBAEO,kBAAkB,IAAI,QAAQ,KAAK,MAAM;;KAEzD,CAAA;IACH,CAAC;CACF;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,UAAoB;IAC3C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAA;QACjF,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,KAAK,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;YACzC,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,KAAK,CAAA;YACrC,IAAI,IAAI,KAAK,KAAK;gBAAE,OAAO,KAAK,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAA;YAClD,IAAI,IAAI,KAAK,MAAM;gBAAE,OAAO,KAAK,GAAG,GAAG,CAAA;YACvC,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -5,9 +5,10 @@ import { ItemContext, Locator } from '../../../locators';
|
|
|
5
5
|
import { MaterialDescription } from '../MaterialDescription';
|
|
6
6
|
import { ItemAnimations } from './ItemAnimations';
|
|
7
7
|
import { MaterialGameAnimationContext } from './MaterialGameAnimations';
|
|
8
|
+
import { Trajectory } from './Trajectory';
|
|
8
9
|
export declare class MaterialAnimations<P extends number = number, M extends number = number, L extends number = number> extends Animations<MaterialGame<P, M, L>, MaterialMove<P, M, L>, P> {
|
|
9
10
|
protected readonly animations: Partial<Record<ItemMoveType, ItemAnimations<P, M, L>>>;
|
|
10
|
-
constructor(duration?: number, droppedItemDuration?: number);
|
|
11
|
+
constructor(duration?: number, droppedItemDuration?: number, trajectory?: Trajectory<P, M, L>);
|
|
11
12
|
getDuration(move: ItemMove<P, M, L>, context: MaterialGameAnimationContext<P, M, L>): number;
|
|
12
13
|
getItemAnimation(context: ItemContext<P, M, L>, animation: Animation<MaterialMove<P, M, L>>, boundaries: GridBoundaries): Interpolation<Theme>;
|
|
13
14
|
}
|
|
@@ -9,14 +9,14 @@ import { RollItemAnimations } from './RollItemAnimations';
|
|
|
9
9
|
import { ShuffleAnimations } from './ShuffleAnimations';
|
|
10
10
|
export class MaterialAnimations extends Animations {
|
|
11
11
|
animations;
|
|
12
|
-
constructor(duration = 1, droppedItemDuration = 0.2) {
|
|
12
|
+
constructor(duration = 1, droppedItemDuration = 0.2, trajectory) {
|
|
13
13
|
super();
|
|
14
14
|
this.animations = {
|
|
15
|
-
[ItemMoveType.Create]: new CreateItemAnimations(duration),
|
|
16
|
-
[ItemMoveType.Move]: new MoveItemAnimations(duration, droppedItemDuration),
|
|
17
|
-
[ItemMoveType.MoveAtOnce]: new MoveItemAtOnceAnimations(duration),
|
|
18
|
-
[ItemMoveType.Delete]: new DeleteItemAnimations(duration, droppedItemDuration),
|
|
19
|
-
[ItemMoveType.DeleteAtOnce]: new DeleteItemAtOnceAnimations(duration),
|
|
15
|
+
[ItemMoveType.Create]: new CreateItemAnimations(duration, trajectory),
|
|
16
|
+
[ItemMoveType.Move]: new MoveItemAnimations(duration, droppedItemDuration, trajectory),
|
|
17
|
+
[ItemMoveType.MoveAtOnce]: new MoveItemAtOnceAnimations(duration, trajectory),
|
|
18
|
+
[ItemMoveType.Delete]: new DeleteItemAnimations(duration, droppedItemDuration, trajectory),
|
|
19
|
+
[ItemMoveType.DeleteAtOnce]: new DeleteItemAtOnceAnimations(duration, trajectory),
|
|
20
20
|
[ItemMoveType.Shuffle]: new ShuffleAnimations(0),
|
|
21
21
|
[ItemMoveType.Roll]: new RollItemAnimations(duration)
|
|
22
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaterialAnimations.js","sourceRoot":"","sources":["../../../../src/components/material/animations/MaterialAnimations.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAA4B,YAAY,EAA6C,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAGjI,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAA;AAGzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"MaterialAnimations.js","sourceRoot":"","sources":["../../../../src/components/material/animations/MaterialAnimations.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAA4B,YAAY,EAA6C,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAGjI,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAA;AAGzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAGvD,MAAM,OAAO,kBACX,SAAQ,UAA2D;IAEhD,UAAU,CAAwD;IAErF,YAAY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,116 @@
|
|
|
1
1
|
import { Interpolation, Theme } from '@emotion/react';
|
|
2
2
|
import { Animation, AnimationContext, Animations, DisplayedAction } from '@gamepark/react-client';
|
|
3
|
-
import { GridBoundaries, MaterialGame, MaterialMove } from '@gamepark/rules-api';
|
|
3
|
+
import { GridBoundaries, ItemMove, MaterialGame, MaterialMove } from '@gamepark/rules-api';
|
|
4
4
|
import { ItemContext, MaterialContext } from '../../../locators';
|
|
5
5
|
import { GameContext } from '../../GameProvider';
|
|
6
6
|
import { MaterialSoundConfig } from '../sound';
|
|
7
|
+
import { AnimationBuilder, AnimationPredicate } from './AnimationBuilder';
|
|
7
8
|
import { ItemAnimations } from './ItemAnimations';
|
|
8
9
|
export type MaterialGameAnimationContext<P extends number = number, M extends number = number, L extends number = number> = AnimationContext<MaterialGame<P, M, L>, MaterialMove<P, M, L>, P> & Omit<GameContext<MaterialGame<P, M, L>, MaterialMove<P, M, L>, P, M, L>, 'game'>;
|
|
9
10
|
export type MaterialAnimationContext<P extends number = number, M extends number = number, L extends number = number> = MaterialContext<P, M, L> & {
|
|
10
11
|
action: DisplayedAction<MaterialMove<P, M, L>, P>;
|
|
11
12
|
};
|
|
12
13
|
export declare class MaterialGameAnimations<P extends number = number, M extends number = number, L extends number = number> extends Animations<MaterialGame<P, M, L>, MaterialMove<P, M, L>, P> {
|
|
14
|
+
/** @internal Animation configurations from the legacy .when() API */
|
|
13
15
|
readonly animationConfigs: AnimationConfig<P, M, L>[];
|
|
16
|
+
/** @internal Animation builders from the new .configure() API */
|
|
17
|
+
readonly animationBuilders: AnimationBuilder<P, M, L>[];
|
|
18
|
+
/** @internal Default animation configuration */
|
|
14
19
|
defaultAnimationConfig: AnimationConfig<P, M, L>;
|
|
20
|
+
/** @internal Default animation builder for new API */
|
|
21
|
+
private _defaultBuilder;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Use configure() instead for the new trajectory API.
|
|
24
|
+
* Create a new animation configuration with filter chain.
|
|
25
|
+
*/
|
|
15
26
|
when(): AnimationConfig<P, M, L>;
|
|
27
|
+
/**
|
|
28
|
+
* Configure animations for moves matching a predicate.
|
|
29
|
+
* @param predicate Function to determine if this configuration applies
|
|
30
|
+
* @returns AnimationBuilder for fluent configuration
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* animations.configure(and(isRule(RuleId.PlayCard), isMyMove()))
|
|
35
|
+
* .duration(800)
|
|
36
|
+
* .arc(15)
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
configure(predicate: AnimationPredicate<P, M, L>): AnimationBuilder<P, M, L>;
|
|
40
|
+
/**
|
|
41
|
+
* Configure animations for moves during a specific rule.
|
|
42
|
+
* @param ruleId The rule ID to match
|
|
43
|
+
* @returns AnimationBuilder for fluent configuration
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* animations.forRule(RuleId.PlayCard)
|
|
48
|
+
* .duration(600)
|
|
49
|
+
* .via(LocationType.TableCenter)
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
forRule(ruleId: number): AnimationBuilder<P, M, L>;
|
|
53
|
+
/**
|
|
54
|
+
* Configure animations for a specific item move type.
|
|
55
|
+
* @param moveType The item move type to match (Create, Move, Delete, etc.)
|
|
56
|
+
* @returns AnimationBuilder for fluent configuration
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* animations.forMove(ItemMoveType.Move)
|
|
61
|
+
* .duration(500)
|
|
62
|
+
* .arc(12)
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
forMove(moveType: ItemMove<P, M, L>['type']): AnimationBuilder<P, M, L>;
|
|
66
|
+
/**
|
|
67
|
+
* Configure animations for a specific material type.
|
|
68
|
+
* @param materialType The material type to match
|
|
69
|
+
* @returns AnimationBuilder for fluent configuration
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* animations.forMaterial(MaterialType.Card)
|
|
74
|
+
* .duration(400)
|
|
75
|
+
* .flat() // No arc for cards
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
forMaterial(materialType: M): AnimationBuilder<P, M, L>;
|
|
79
|
+
/**
|
|
80
|
+
* Configure default animations (applies to all moves not matched by other configurations).
|
|
81
|
+
* @returns AnimationBuilder for fluent configuration
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* animations.defaults()
|
|
86
|
+
* .duration(600)
|
|
87
|
+
* .arc({ height: 8, peak: 0.4 })
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
defaults(): AnimationBuilder<P, M, L>;
|
|
16
91
|
getDuration(move: MaterialMove<P, M, L>, context: MaterialGameAnimationContext<P, M, L>): number;
|
|
92
|
+
/**
|
|
93
|
+
* Find matching animation builder from new API.
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
getAnimationBuilder(move: MaterialMove<P, M, L>, context: MaterialAnimationContext<P, M, L>): AnimationBuilder<P, M, L> | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Find matching animation config from legacy API.
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
17
101
|
getAnimationConfig(move: MaterialMove<P, M, L>, context: MaterialAnimationContext<P, M, L>): AnimationConfig<P, M, L>;
|
|
102
|
+
/**
|
|
103
|
+
* Get item animation CSS, checking both new and legacy APIs.
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
getItemAnimation(context: ItemContext<P, M, L>, animation: Animation<MaterialMove<P, M, L>>, action: DisplayedAction<MaterialMove<P, M, L>, P>, boundaries: GridBoundaries): Interpolation<Theme>;
|
|
18
107
|
getSounds(): string[];
|
|
19
108
|
pauseNextConsequenceAnimation(move: MaterialMove<P, M, L>, _context: AnimationContext<MaterialGame<P, M, L>, MaterialMove<P, M, L>, P>): boolean;
|
|
20
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* @deprecated Use AnimationBuilder with the new configure() API instead.
|
|
112
|
+
* Legacy animation configuration class for backward compatibility.
|
|
113
|
+
*/
|
|
21
114
|
declare class AnimationConfig<P extends number = number, M extends number = number, L extends number = number> extends ItemAnimations<P, M, L> {
|
|
22
115
|
filters: ((move: MaterialMove<P, M, L>, context: MaterialAnimationContext<P, M, L>) => boolean)[];
|
|
23
116
|
d?: number;
|