@gamepark/react-game 6.0.0-alpha.0 → 6.2.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/Avatar/Avatar.js +7 -5
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/GameProvider/GameContext.d.ts +1 -0
- package/dist/components/GameProvider/GameContext.js.map +1 -1
- package/dist/components/GameProvider/GameProvider.d.ts +1 -1
- package/dist/components/GameProvider/GameProvider.js +13 -4
- package/dist/components/GameProvider/GameProvider.js.map +1 -1
- package/dist/components/ImagesLoader/ImagesLoader.d.ts +2 -3
- package/dist/components/ImagesLoader/ImagesLoader.js.map +1 -1
- package/dist/components/buttons/PlayMoveButton/PlayMoveButton.js +25 -10
- package/dist/components/buttons/PlayMoveButton/PlayMoveButton.js.map +1 -1
- package/dist/components/dialogs/ResultDialog/ResultDialog.js +22 -17
- package/dist/components/dialogs/ResultDialog/ResultDialog.js.map +1 -1
- package/dist/components/dialogs/RulesDialog/LocationRulesDialogContent.d.ts +4 -9
- package/dist/components/dialogs/RulesDialog/LocationRulesDialogContent.js +7 -7
- package/dist/components/dialogs/RulesDialog/LocationRulesDialogContent.js.map +1 -1
- package/dist/components/dialogs/RulesDialog/MaterialRulesDialog.js +5 -17
- package/dist/components/dialogs/RulesDialog/MaterialRulesDialog.js.map +1 -1
- package/dist/components/dialogs/RulesDialog/MaterialRulesDialogContent.d.ts +3 -6
- package/dist/components/dialogs/RulesDialog/MaterialRulesDialogContent.js +8 -8
- package/dist/components/dialogs/RulesDialog/MaterialRulesDialogContent.js.map +1 -1
- package/dist/components/dialogs/RulesDialog/RulesDialog.d.ts +1 -0
- package/dist/components/dialogs/RulesDialog/RulesDialog.js +3 -3
- package/dist/components/dialogs/RulesDialog/RulesDialog.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/material/DraggableMaterial.d.ts +14 -11
- package/dist/components/material/DraggableMaterial.js +102 -48
- package/dist/components/material/DraggableMaterial.js.map +1 -1
- package/dist/components/material/FlatMaterial/BoardDescription.d.ts +3 -0
- package/dist/components/material/FlatMaterial/BoardDescription.js +28 -0
- package/dist/components/material/FlatMaterial/BoardDescription.js.map +1 -0
- package/dist/components/material/FlatMaterial/CardDescription.d.ts +6 -0
- package/dist/components/material/FlatMaterial/CardDescription.js +32 -0
- package/dist/components/material/FlatMaterial/CardDescription.js.map +1 -0
- package/dist/components/material/FlatMaterial/FlatMaterial.d.ts +35 -0
- package/dist/components/material/FlatMaterial/FlatMaterial.js +128 -0
- package/dist/components/material/FlatMaterial/FlatMaterial.js.map +1 -0
- package/dist/components/material/FlatMaterial/TokenDescription.d.ts +10 -0
- package/dist/components/material/FlatMaterial/TokenDescription.js +44 -0
- package/dist/components/material/FlatMaterial/TokenDescription.js.map +1 -0
- package/dist/components/material/FlatMaterial/index.d.ts +4 -0
- package/dist/components/material/{Card → FlatMaterial}/index.js +4 -1
- package/dist/components/material/FlatMaterial/index.js.map +1 -0
- package/dist/components/material/GameTable/GameMaterialDisplay.js +64 -45
- package/dist/components/material/GameTable/GameMaterialDisplay.js.map +1 -1
- package/dist/components/material/GameTable/GameTable.d.ts +2 -2
- package/dist/components/material/GameTable/GameTable.js +64 -16
- package/dist/components/material/GameTable/GameTable.js.map +1 -1
- package/dist/components/material/GameTable/GameTableContent.js +22 -7
- package/dist/components/material/GameTable/GameTableContent.js.map +1 -1
- package/dist/components/material/ImageLoader/MaterialImageLoader.d.ts +5 -0
- package/dist/components/material/ImageLoader/MaterialImageLoader.js +33 -0
- package/dist/components/material/ImageLoader/MaterialImageLoader.js.map +1 -0
- package/dist/components/material/ImageLoader/index.d.ts +1 -0
- package/dist/components/material/{Token → ImageLoader}/index.js +1 -1
- package/dist/components/material/ImageLoader/index.js.map +1 -0
- package/dist/components/material/MaterialAnimations.d.ts +11 -14
- package/dist/components/material/MaterialAnimations.js +129 -82
- package/dist/components/material/MaterialAnimations.js.map +1 -1
- package/dist/components/material/MaterialComponent.d.ts +5 -10
- package/dist/components/material/MaterialComponent.js +8 -53
- package/dist/components/material/MaterialComponent.js.map +1 -1
- package/dist/components/material/MaterialDescription.d.ts +31 -18
- package/dist/components/material/MaterialDescription.js +36 -0
- package/dist/components/material/MaterialDescription.js.map +1 -1
- package/dist/components/material/animations/CreateItemAnimations.d.ts +14 -0
- package/dist/components/material/animations/CreateItemAnimations.js +72 -0
- package/dist/components/material/animations/CreateItemAnimations.js.map +1 -0
- package/dist/components/material/animations/DeleteItemAnimations.d.ts +14 -0
- package/dist/components/material/animations/DeleteItemAnimations.js +80 -0
- package/dist/components/material/animations/DeleteItemAnimations.js.map +1 -0
- package/dist/components/material/animations/ItemAnimations.d.ts +7 -0
- package/dist/components/material/animations/ItemAnimations.js +31 -0
- package/dist/components/material/animations/ItemAnimations.js.map +1 -0
- package/dist/components/material/animations/MaterialAnimations.d.ts +19 -0
- package/dist/components/material/animations/MaterialAnimations.js +51 -0
- package/dist/components/material/animations/MaterialAnimations.js.map +1 -0
- package/dist/components/material/animations/MaterialGameAnimations.d.ts +11 -0
- package/dist/components/material/animations/MaterialGameAnimations.js +42 -0
- package/dist/components/material/animations/MaterialGameAnimations.js.map +1 -0
- package/dist/components/material/animations/MoveItemAnimations.d.ts +16 -0
- package/dist/components/material/animations/MoveItemAnimations.js +105 -0
- package/dist/components/material/animations/MoveItemAnimations.js.map +1 -0
- package/dist/components/material/animations/ShuffleAnimations.d.ts +8 -0
- package/dist/components/material/animations/ShuffleAnimations.js +34 -0
- package/dist/components/material/animations/ShuffleAnimations.js.map +1 -0
- package/dist/components/material/animations/adjustRotation.d.ts +1 -0
- package/dist/components/material/animations/adjustRotation.js +37 -0
- package/dist/components/material/animations/adjustRotation.js.map +1 -0
- package/dist/components/material/animations/getFirstStockItemTransforms.util.d.ts +2 -0
- package/dist/components/material/animations/getFirstStockItemTransforms.util.js +32 -0
- package/dist/components/material/animations/getFirstStockItemTransforms.util.js.map +1 -0
- package/dist/components/material/animations/index.d.ts +9 -0
- package/dist/components/material/animations/index.js +29 -0
- package/dist/components/material/animations/index.js.map +1 -0
- package/dist/components/material/animations/isMovedOrDeletedItem.util.d.ts +3 -0
- package/dist/components/material/animations/isMovedOrDeletedItem.util.js +28 -0
- package/dist/components/material/animations/isMovedOrDeletedItem.util.js.map +1 -0
- package/dist/components/material/animations/itemMovementCss.util.d.ts +2 -0
- package/dist/components/material/animations/itemMovementCss.util.js +13 -0
- package/dist/components/material/animations/itemMovementCss.util.js.map +1 -0
- package/dist/components/material/animations/transformItem.util.d.ts +2 -0
- package/dist/components/material/animations/transformItem.util.js +11 -0
- package/dist/components/material/animations/transformItem.util.js.map +1 -0
- package/dist/components/material/index.d.ts +4 -7
- package/dist/components/material/index.js +4 -7
- package/dist/components/material/index.js.map +1 -1
- package/dist/components/material/locations/LocationDescription.d.ts +28 -0
- package/dist/components/material/locations/LocationDescription.js +54 -0
- package/dist/components/material/locations/LocationDescription.js.map +1 -0
- package/dist/components/material/locations/LocationsMask.d.ts +5 -0
- package/dist/components/material/locations/LocationsMask.js +48 -0
- package/dist/components/material/locations/LocationsMask.js.map +1 -0
- package/dist/components/material/locations/SimpleDropArea.d.ts +13 -0
- package/dist/components/material/{DropAreas → locations}/SimpleDropArea.js +44 -30
- package/dist/components/material/locations/SimpleDropArea.js.map +1 -0
- package/dist/components/material/locations/index.d.ts +3 -0
- package/dist/components/material/{Board → locations}/index.js +3 -1
- package/dist/components/material/locations/index.js.map +1 -0
- package/dist/components/material/utils/getItemFromContext.d.ts +3 -0
- package/dist/components/material/utils/getItemFromContext.js +10 -0
- package/dist/components/material/utils/getItemFromContext.js.map +1 -0
- package/dist/components/material/utils/index.d.ts +0 -3
- package/dist/components/material/utils/index.js +0 -3
- package/dist/components/material/utils/index.js.map +1 -1
- package/dist/components/material/utils/isDroppedItem.d.ts +2 -0
- package/dist/components/material/utils/isDroppedItem.js +15 -0
- package/dist/components/material/utils/isDroppedItem.js.map +1 -0
- package/dist/components/material/utils/isPlacedOnItem.d.ts +3 -0
- package/dist/components/material/utils/isPlacedOnItem.js +15 -0
- package/dist/components/material/utils/isPlacedOnItem.js.map +1 -0
- package/dist/components/material/utils/useIsAnimatingPlayerAction.d.ts +1 -0
- package/dist/components/material/utils/useIsAnimatingPlayerAction.js +10 -0
- package/dist/components/material/utils/useIsAnimatingPlayerAction.js.map +1 -0
- package/dist/components/menus/Menu/Menu.js +3 -3
- package/dist/components/menus/Menu/Menu.js.map +1 -1
- package/dist/components/menus/Result/ResultPopButton.js +1 -1
- package/dist/components/menus/Result/ResultPopButton.js.map +1 -1
- package/dist/components/tutorial/MaterialTutorial.d.ts +47 -0
- package/dist/components/tutorial/MaterialTutorial.js +95 -0
- package/dist/components/tutorial/MaterialTutorial.js.map +1 -0
- package/dist/components/tutorial/MaterialTutorialDisplay.d.ts +1 -0
- package/dist/components/tutorial/MaterialTutorialDisplay.js +73 -0
- package/dist/components/tutorial/MaterialTutorialDisplay.js.map +1 -0
- package/dist/components/tutorial/TutorialRulesWrapper.d.ts +3 -0
- package/dist/components/tutorial/TutorialRulesWrapper.js +60 -0
- package/dist/components/tutorial/TutorialRulesWrapper.js.map +1 -0
- package/dist/components/tutorial/index.d.ts +1 -0
- package/dist/components/{material/DropAreas → tutorial}/index.js +1 -1
- package/dist/components/tutorial/index.js.map +1 -0
- package/dist/css/componentSizeCss.d.ts +1 -5
- package/dist/css/componentSizeCss.js +1 -1
- package/dist/css/componentSizeCss.js.map +1 -1
- package/dist/css/fadeIn.d.ts +1 -0
- package/dist/css/fadeIn.js +13 -0
- package/dist/css/fadeIn.js.map +1 -0
- package/dist/css/index.d.ts +2 -0
- package/dist/css/index.js +2 -0
- package/dist/css/index.js.map +1 -1
- package/dist/css/shadowEffect.d.ts +1 -0
- package/dist/css/shadowEffect.js +11 -0
- package/dist/css/shadowEffect.js.map +1 -0
- package/dist/css/transformCss.d.ts +1 -0
- package/dist/css/transformCss.js +3 -2
- package/dist/css/transformCss.js.map +1 -1
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +3 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useItemLocator.js +2 -3
- package/dist/hooks/useItemLocator.js.map +1 -1
- package/dist/hooks/useLegalMoves.js +11 -6
- package/dist/hooks/useLegalMoves.js.map +1 -1
- package/dist/hooks/useLocators.d.ts +1 -0
- package/dist/hooks/useLocators.js +8 -0
- package/dist/hooks/useLocators.js.map +1 -0
- package/dist/hooks/useMaterialContext.d.ts +2 -0
- package/dist/hooks/useMaterialContext.js +18 -0
- package/dist/hooks/useMaterialContext.js.map +1 -0
- package/dist/hooks/useMaterials.d.ts +2 -0
- package/dist/hooks/useMaterials.js +10 -0
- package/dist/hooks/useMaterials.js.map +1 -0
- package/dist/hooks/usePlayerName.js +12 -1
- package/dist/hooks/usePlayerName.js.map +1 -1
- package/dist/hooks/usePlayers.js +1 -1
- package/dist/hooks/usePlayers.js.map +1 -1
- package/dist/hooks/useRulesStep.d.ts +2 -0
- package/dist/hooks/useRulesStep.js +10 -0
- package/dist/hooks/useRulesStep.js.map +1 -0
- package/dist/hooks/useTutorialStep.d.ts +2 -0
- package/dist/hooks/useTutorialStep.js +15 -0
- package/dist/hooks/useTutorialStep.js.map +1 -0
- package/dist/hooks/useZoomToElements.d.ts +5 -0
- package/dist/hooks/useZoomToElements.js +65 -0
- package/dist/hooks/useZoomToElements.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/locators/DeckLocator.d.ts +4 -4
- package/dist/locators/DeckLocator.js +3 -2
- package/dist/locators/DeckLocator.js.map +1 -1
- package/dist/locators/HandLocator.d.ts +11 -11
- package/dist/locators/HandLocator.js.map +1 -1
- package/dist/locators/ItemLocator.d.ts +31 -41
- package/dist/locators/ItemLocator.js +33 -90
- package/dist/locators/ItemLocator.js.map +1 -1
- package/dist/locators/LineLocator.d.ts +7 -5
- package/dist/locators/LineLocator.js +10 -1
- package/dist/locators/LineLocator.js.map +1 -1
- package/dist/locators/PileLocator.d.ts +8 -6
- package/dist/locators/PileLocator.js +13 -1
- package/dist/locators/PileLocator.js.map +1 -1
- package/dist/utilities/animations.constants.d.ts +16 -0
- package/dist/utilities/animations.constants.js +82 -0
- package/dist/utilities/animations.constants.js.map +1 -0
- package/dist/utilities/animations.util.d.ts +4 -0
- package/dist/utilities/animations.util.js +78 -0
- package/dist/utilities/animations.util.js.map +1 -0
- package/dist/utilities/bounds.util.d.ts +18 -0
- package/dist/utilities/bounds.util.js +85 -0
- package/dist/utilities/bounds.util.js.map +1 -0
- package/dist/utilities/calculation.util.d.ts +14 -0
- package/dist/utilities/calculation.util.js +24 -0
- package/dist/utilities/calculation.util.js.map +1 -0
- package/dist/utilities/zoom.util.d.ts +4 -0
- package/dist/utilities/zoom.util.js +17 -0
- package/dist/utilities/zoom.util.js.map +1 -0
- package/package.json +7 -5
- package/dist/components/material/Board/Board.d.ts +0 -17
- package/dist/components/material/Board/Board.js +0 -34
- package/dist/components/material/Board/Board.js.map +0 -1
- package/dist/components/material/Board/index.d.ts +0 -1
- package/dist/components/material/Board/index.js.map +0 -1
- package/dist/components/material/Card/Card.d.ts +0 -23
- package/dist/components/material/Card/Card.js +0 -49
- package/dist/components/material/Card/Card.js.map +0 -1
- package/dist/components/material/Card/index.d.ts +0 -1
- package/dist/components/material/Card/index.js.map +0 -1
- package/dist/components/material/DropAreas/SimpleDropArea.d.ts +0 -12
- package/dist/components/material/DropAreas/SimpleDropArea.js.map +0 -1
- package/dist/components/material/DropAreas/index.d.ts +0 -1
- package/dist/components/material/DropAreas/index.js.map +0 -1
- package/dist/components/material/Items.d.ts +0 -4
- package/dist/components/material/Items.js +0 -3
- package/dist/components/material/Items.js.map +0 -1
- package/dist/components/material/Token/Token.d.ts +0 -18
- package/dist/components/material/Token/Token.js +0 -34
- package/dist/components/material/Token/Token.js.map +0 -1
- package/dist/components/material/Token/index.d.ts +0 -1
- package/dist/components/material/Token/index.js.map +0 -1
- package/dist/components/material/utils/IsMoveThisItem.d.ts +0 -2
- package/dist/components/material/utils/IsMoveThisItem.js +0 -12
- package/dist/components/material/utils/IsMoveThisItem.js.map +0 -1
- package/dist/components/material/utils/IsMoveThisItemToLocation.d.ts +0 -3
- package/dist/components/material/utils/IsMoveThisItemToLocation.js +0 -11
- package/dist/components/material/utils/IsMoveThisItemToLocation.js.map +0 -1
- package/dist/components/material/utils/IsMoveToLocation.d.ts +0 -2
- package/dist/components/material/utils/IsMoveToLocation.js +0 -13
- package/dist/components/material/utils/IsMoveToLocation.js.map +0 -1
- package/dist/components/material/utils/IsMoveToStock.d.ts +0 -4
- package/dist/components/material/utils/IsMoveToStock.js +0 -18
- package/dist/components/material/utils/IsMoveToStock.js.map +0 -1
- package/dist/hooks/useStocks.d.ts +0 -2
- package/dist/hooks/useStocks.js +0 -12
- package/dist/hooks/useStocks.js.map +0 -1
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
2
|
var __assign = (this && this.__assign) || function () {
|
|
7
3
|
__assign = Object.assign || function(t) {
|
|
8
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -28,17 +24,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
24
|
};
|
|
29
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
26
|
exports.ItemLocator = void 0;
|
|
31
|
-
var jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
32
27
|
/** @jsxImportSource @emotion/react */
|
|
33
28
|
var rules_api_1 = require("@gamepark/rules-api");
|
|
34
|
-
var components_1 = require("../components");
|
|
35
|
-
var react_1 = require("@emotion/react");
|
|
36
29
|
var fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
37
|
-
var
|
|
38
|
-
var IsMoveToStock_1 = require("../components/material/utils/IsMoveToStock");
|
|
30
|
+
var sumBy_1 = __importDefault(require("lodash/sumBy"));
|
|
39
31
|
var ItemLocator = /** @class */ (function () {
|
|
40
32
|
function ItemLocator() {
|
|
41
33
|
this.rotationUnit = 'deg';
|
|
34
|
+
this.position = { x: 0, y: 0 };
|
|
35
|
+
this.positionOnParent = { x: 0, y: 0 };
|
|
36
|
+
this.hidden = false;
|
|
42
37
|
}
|
|
43
38
|
ItemLocator.prototype.hide = function (item, context) {
|
|
44
39
|
return this.limit ? this.getItemIndex(item, context) >= this.limit : false;
|
|
@@ -54,16 +49,13 @@ var ItemLocator = /** @class */ (function () {
|
|
|
54
49
|
return __spreadArray([this.getTranslate3d(item, context)], this.getRotations(item, context), true);
|
|
55
50
|
};
|
|
56
51
|
ItemLocator.prototype.getTranslate3d = function (item, context) {
|
|
57
|
-
var _a;
|
|
58
|
-
var _b = this.getPosition(item, context), x = _b.x, y = _b.y, z = _b.z;
|
|
52
|
+
var _a = this.getPosition(item, context), x = _a.x, y = _a.y, z = _a.z;
|
|
59
53
|
var parentMaterial = this.parentItemType ? context.material[this.parentItemType] : undefined;
|
|
60
54
|
if (parentMaterial) {
|
|
61
|
-
var positionOnParent =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
y += height * (positionOnParent.y - 50) / 100;
|
|
66
|
-
}
|
|
55
|
+
var positionOnParent = this.getPositionOnParent(item.location, context);
|
|
56
|
+
var _b = parentMaterial.getSize(this.getParentItemId(item.location)), width = _b.width, height = _b.height;
|
|
57
|
+
x += width * (positionOnParent.x - 50) / 100;
|
|
58
|
+
y += height * (positionOnParent.y - 50) / 100;
|
|
67
59
|
}
|
|
68
60
|
return "translate3d(".concat(x, "em, ").concat(y, "em, ").concat(z, "em)");
|
|
69
61
|
};
|
|
@@ -78,7 +70,19 @@ var ItemLocator = /** @class */ (function () {
|
|
|
78
70
|
* @return The delta coordinates in em of the center of the item from the center of their parent (or the screen)
|
|
79
71
|
*/
|
|
80
72
|
ItemLocator.prototype.getPosition = function (item, context) {
|
|
81
|
-
return {
|
|
73
|
+
return __assign(__assign({}, this.position), { z: context.material[context.type].getThickness(item, context) });
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Place the center of the item in the plan of their parent item. This is ignored if "parentItemType" is undefined.
|
|
77
|
+
* Examples: {x: 0, y: 0} places the center of the item in the top-left corner of the parent item
|
|
78
|
+
* {x: 50, y: 50} centers the item in the parent item.
|
|
79
|
+
*
|
|
80
|
+
* @param _location Location of the item or area inside the parent item
|
|
81
|
+
* @param _context THe material game context
|
|
82
|
+
* @return {x, y} with "x" as a percentage from the parent's width, "y" a percentage of the height
|
|
83
|
+
*/
|
|
84
|
+
ItemLocator.prototype.getPositionOnParent = function (_location, _context) {
|
|
85
|
+
return this.positionOnParent;
|
|
82
86
|
};
|
|
83
87
|
ItemLocator.prototype.getRotations = function (item, context) {
|
|
84
88
|
var _a;
|
|
@@ -93,73 +97,43 @@ var ItemLocator = /** @class */ (function () {
|
|
|
93
97
|
return rotations;
|
|
94
98
|
};
|
|
95
99
|
ItemLocator.prototype.isHidden = function (_item, _context) {
|
|
96
|
-
return
|
|
100
|
+
return this.hidden;
|
|
97
101
|
};
|
|
98
102
|
ItemLocator.prototype.transformParentItemLocation = function (location, context) {
|
|
99
|
-
var _a;
|
|
100
103
|
if (!this.parentItemType)
|
|
101
104
|
return [];
|
|
102
|
-
var game = context.game,
|
|
105
|
+
var game = context.game, material = context.material, locators = context.locators;
|
|
103
106
|
var parentMaterial = material[this.parentItemType];
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var parentItem = game.items[this.parentItemType][parentItemIndex];
|
|
107
|
+
if (location.parent !== undefined) {
|
|
108
|
+
var parentItem = game.items[this.parentItemType][location.parent];
|
|
107
109
|
var parentLocator = locators[parentItem.location.type];
|
|
108
|
-
return parentLocator.transformItemLocation(parentItem, __assign(__assign({}, context), { type: this.parentItemType,
|
|
110
|
+
return parentLocator.transformItemLocation(parentItem, __assign(__assign({}, context), { type: this.parentItemType, displayIndex: 0 }));
|
|
109
111
|
}
|
|
110
112
|
else {
|
|
111
113
|
var parentItemId_1 = this.getParentItemId(location);
|
|
112
|
-
var staticItem = parentMaterial.
|
|
114
|
+
var staticItem = parentMaterial.getStaticItems(context).find(function (item) { return (0, fast_deep_equal_1.default)(item.id, parentItemId_1); });
|
|
113
115
|
if (!staticItem)
|
|
114
116
|
return [];
|
|
115
117
|
var locator = locators[staticItem.location.type];
|
|
116
|
-
return locator.transformItemLocation(staticItem, __assign(__assign({}, context), { type: this.parentItemType,
|
|
118
|
+
return locator.transformItemLocation(staticItem, __assign(__assign({}, context), { type: this.parentItemType, displayIndex: 0 }));
|
|
117
119
|
}
|
|
118
120
|
};
|
|
119
|
-
ItemLocator.prototype.getItemThickness = function (_item, _context) {
|
|
120
|
-
return 0.05;
|
|
121
|
-
};
|
|
122
121
|
ItemLocator.prototype.getItemIndex = function (item, context) {
|
|
123
122
|
var _a, _b, _c;
|
|
124
|
-
return (_c = (_b = (_a = item.location.x) !== null && _a !== void 0 ? _a : item.location.y) !== null && _b !== void 0 ? _b : item.location.z) !== null && _c !== void 0 ? _c : context.
|
|
123
|
+
return (_c = (_b = (_a = item.location.x) !== null && _a !== void 0 ? _a : item.location.y) !== null && _b !== void 0 ? _b : item.location.z) !== null && _c !== void 0 ? _c : context.displayIndex;
|
|
125
124
|
};
|
|
126
125
|
ItemLocator.prototype.isSameLocation = function (location1, location2) {
|
|
127
126
|
return location1.type === location2.type && location1.player === location2.player && location1.parent === location2.parent;
|
|
128
127
|
};
|
|
129
|
-
ItemLocator.prototype.countItems = function (location,
|
|
128
|
+
ItemLocator.prototype.countItems = function (location, _a) {
|
|
130
129
|
var _this = this;
|
|
131
|
-
var
|
|
132
|
-
|
|
133
|
-
return 0;
|
|
134
|
-
return items.reduce(function (sum, item) { var _a; return _this.isSameLocation(item.location, location) ? sum + ((_a = item.quantity) !== null && _a !== void 0 ? _a : 1) : sum; }, 0);
|
|
130
|
+
var game = _a.game, type = _a.type;
|
|
131
|
+
return game.items[type] ? (0, sumBy_1.default)(game.items[type], function (item) { var _a; return _this.isSameLocation(item.location, location) ? ((_a = item.quantity) !== null && _a !== void 0 ? _a : 1) : 0; }) : 0;
|
|
135
132
|
};
|
|
136
133
|
ItemLocator.prototype.getMaterial = function (game, type) {
|
|
137
134
|
var _a;
|
|
138
135
|
return new rules_api_1.Material(type, Array.from(((_a = game.items[type]) !== null && _a !== void 0 ? _a : []).entries()).filter(function (entry) { return entry[1].quantity !== 0; }));
|
|
139
136
|
};
|
|
140
|
-
ItemLocator.prototype.createLocationsOnItem = function (parent, legalMoves, rules) {
|
|
141
|
-
var _this = this;
|
|
142
|
-
var _a, _b;
|
|
143
|
-
var locations = (_b = (_a = this.getParentItemLocations) === null || _a === void 0 ? void 0 : _a.call(this, parent)) !== null && _b !== void 0 ? _b : [];
|
|
144
|
-
return locations.map(function (location) { return _this.createLocation(location, rules, legalMoves.filter(function (move) { return rules.isMoveTrigger(move, function (move) { return (0, utils_1.isMoveToLocation)(move, location); }); }), true); });
|
|
145
|
-
};
|
|
146
|
-
ItemLocator.prototype.createLocations = function (legalMoves, rules, context) {
|
|
147
|
-
var _this = this;
|
|
148
|
-
var _a, _b;
|
|
149
|
-
var locations = (_b = (_a = this.getLocations) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : [];
|
|
150
|
-
var stocks = (0, IsMoveToStock_1.getStocks)(context.material);
|
|
151
|
-
return locations.map(function (location) {
|
|
152
|
-
return _this.createLocation(location, rules, legalMoves.filter(function (move) { return rules.isMoveTrigger(move, function (move) { return (0, utils_1.isMoveToLocation)(move, location) || (0, IsMoveToStock_1.isMoveToStock)(stocks, move, location); }); }));
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
ItemLocator.prototype.createLocation = function (location, rules, legalMoves, hasParent) {
|
|
156
|
-
var _a, _b;
|
|
157
|
-
var position = (_b = (_a = this.getPositionOnParent) === null || _a === void 0 ? void 0 : _a.call(this, location)) !== null && _b !== void 0 ? _b : { x: 0, y: 0 };
|
|
158
|
-
return (0, jsx_runtime_1.jsx)(components_1.SimpleDropArea, { location: location, legalMoves: legalMoves, dragOnly: !hasParent, css: [hasParent && childLocationCss(position), this.getLocationCss(location, rules, legalMoves)] }, JSON.stringify(location));
|
|
159
|
-
};
|
|
160
|
-
ItemLocator.prototype.getLocationCss = function (_location, _rules, _legalMoves) {
|
|
161
|
-
return;
|
|
162
|
-
};
|
|
163
137
|
ItemLocator.prototype.getRelativePlayerIndex = function (_a, player) {
|
|
164
138
|
var players = _a.game.players, me = _a.player;
|
|
165
139
|
var absoluteIndex = players.indexOf(player);
|
|
@@ -167,38 +141,7 @@ var ItemLocator = /** @class */ (function () {
|
|
|
167
141
|
return absoluteIndex;
|
|
168
142
|
return (absoluteIndex - players.indexOf(me) + players.length) % players.length;
|
|
169
143
|
};
|
|
170
|
-
ItemLocator.prototype.isItemToAnimate = function (_a, animation, _b) {
|
|
171
|
-
var _c, _d, _e, _f, _g, _h, _j;
|
|
172
|
-
var type = _a.type, index = _a.index, displayIndex = _a.displayIndex;
|
|
173
|
-
var game = _b.rules.game;
|
|
174
|
-
if ((0, rules_api_1.isMoveItem)(animation.move) || (0, rules_api_1.isDeleteItem)(animation.move)) {
|
|
175
|
-
var quantity = (_c = game.items[type][index].quantity) !== null && _c !== void 0 ? _c : 1;
|
|
176
|
-
if (quantity === 1)
|
|
177
|
-
return true;
|
|
178
|
-
if (this.limit)
|
|
179
|
-
quantity = Math.min(quantity, this.limit);
|
|
180
|
-
if (((_d = game.droppedItem) === null || _d === void 0 ? void 0 : _d.type) === type && game.droppedItem.index === index) {
|
|
181
|
-
var droppedIndex = game.droppedItem.displayIndex;
|
|
182
|
-
if (displayIndex === droppedIndex)
|
|
183
|
-
return true;
|
|
184
|
-
if (droppedIndex < quantity - ((_e = animation.move.quantity) !== null && _e !== void 0 ? _e : 1)) {
|
|
185
|
-
return displayIndex > quantity - ((_f = animation.move.quantity) !== null && _f !== void 0 ? _f : 1);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return displayIndex >= quantity - ((_g = animation.move.quantity) !== null && _g !== void 0 ? _g : 1);
|
|
189
|
-
}
|
|
190
|
-
else if ((0, rules_api_1.isCreateItem)(animation.move)) {
|
|
191
|
-
var quantity = (_h = game.items[type][index].quantity) !== null && _h !== void 0 ? _h : 1;
|
|
192
|
-
return displayIndex >= quantity - ((_j = animation.move.item.quantity) !== null && _j !== void 0 ? _j : 1);
|
|
193
|
-
}
|
|
194
|
-
return false;
|
|
195
|
-
};
|
|
196
144
|
return ItemLocator;
|
|
197
145
|
}());
|
|
198
146
|
exports.ItemLocator = ItemLocator;
|
|
199
|
-
var childLocationCss = function (_a) {
|
|
200
|
-
var x = _a.x, y = _a.y;
|
|
201
|
-
return (0, react_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n left: ", "%;\n top: ", "%;\n transform: translate(-50%, -50%);\n"], ["\n position: absolute;\n left: ", "%;\n top: ", "%;\n transform: translate(-50%, -50%);\n"])), x, y);
|
|
202
|
-
};
|
|
203
|
-
var templateObject_1;
|
|
204
147
|
//# sourceMappingURL=ItemLocator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemLocator.js","sourceRoot":"","sources":["../../src/locators/ItemLocator.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ItemLocator.js","sourceRoot":"","sources":["../../src/locators/ItemLocator.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAsC;AACtC,iDAAqJ;AAErJ,oEAAmC;AACnC,uDAAgC;AAEhC;IAAA;QAEE,iBAAY,GAAG,KAAK,CAAA;QAoCpB,aAAQ,GAAkB,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;QAaxC,qBAA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AC,KAAK,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,EAAvB,CAAuB,CAAC,CAAC,CAAA;IAC7H,CAAC;IAED,4CAAsB,GAAtB,UAAuB,EAA2D,EAAE,MAAS;YAA5D,OAAO,kBAAA,EAAY,EAAE,YAAA;QACpD,IAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAC7C,IAAI,EAAE,KAAK,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE;YAAE,OAAO,aAAa,CAAA;QAC/D,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAA;IAChF,CAAC;IACH,kBAAC;AAAD,CAAC,AA5HD,IA4HC;AA5HqB,kCAAW"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ItemContext, ItemLocator } from './ItemLocator';
|
|
2
2
|
import { Coordinates, MaterialItem } from '@gamepark/rules-api';
|
|
3
3
|
export declare abstract class LineLocator<P extends number = number, M extends number = number, L extends number = number> extends ItemLocator<P, M, L> {
|
|
4
|
-
getPosition(item: MaterialItem<P, L>, context:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
getPosition(item: MaterialItem<P, L>, context: ItemContext<P, M, L>): Coordinates;
|
|
5
|
+
coordinates: Coordinates;
|
|
6
|
+
getCoordinates(_item: MaterialItem<P, L>, _context: ItemContext<P, M, L>): Coordinates;
|
|
7
|
+
delta?: Partial<Coordinates>;
|
|
8
|
+
getDelta(_item: MaterialItem<P, L>, _context: ItemContext<P, M, L>): Partial<Coordinates>;
|
|
9
|
+
getDeltaMax?(item: MaterialItem<P, L>, context: ItemContext<P, M, L>): Partial<Coordinates>;
|
|
8
10
|
}
|
|
@@ -20,7 +20,9 @@ var ItemLocator_1 = require("./ItemLocator");
|
|
|
20
20
|
var LineLocator = /** @class */ (function (_super) {
|
|
21
21
|
__extends(LineLocator, _super);
|
|
22
22
|
function LineLocator() {
|
|
23
|
-
|
|
23
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
24
|
+
_this.coordinates = { x: 0, y: 0, z: 0 };
|
|
25
|
+
return _this;
|
|
24
26
|
}
|
|
25
27
|
LineLocator.prototype.getPosition = function (item, context) {
|
|
26
28
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -39,6 +41,13 @@ var LineLocator = /** @class */ (function (_super) {
|
|
|
39
41
|
}
|
|
40
42
|
return { x: coordinates.x + index * ((_d = delta.x) !== null && _d !== void 0 ? _d : 0), y: coordinates.y + index * ((_e = delta.y) !== null && _e !== void 0 ? _e : 0), z: coordinates.z + index * ((_f = delta.z) !== null && _f !== void 0 ? _f : 0) };
|
|
41
43
|
};
|
|
44
|
+
LineLocator.prototype.getCoordinates = function (_item, _context) {
|
|
45
|
+
return this.coordinates;
|
|
46
|
+
};
|
|
47
|
+
LineLocator.prototype.getDelta = function (_item, _context) {
|
|
48
|
+
var _a;
|
|
49
|
+
return (_a = this.delta) !== null && _a !== void 0 ? _a : {};
|
|
50
|
+
};
|
|
42
51
|
return LineLocator;
|
|
43
52
|
}(ItemLocator_1.ItemLocator));
|
|
44
53
|
exports.LineLocator = LineLocator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineLocator.js","sourceRoot":"","sources":["../../src/locators/LineLocator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"LineLocator.js","sourceRoot":"","sources":["../../src/locators/LineLocator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6CAAwD;AAGxD;IAA2H,+BAAoB;IAA/I;QAAA,qEA4BC;QAbC,iB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AC,MAAA,KAAK,CAAC,CAAC,mCAAI,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,MAAA,KAAK,CAAC,CAAC,mCAAI,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,MAAA,KAAK,CAAC,CAAC,mCAAI,CAAC,CAAC,EAAE,CAAA;IAC5I,CAAC;IAID,oCAAc,GAAd,UAAe,KAAyB,EAAE,QAA8B;QACtE,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;IAID,8BAAQ,GAAR,UAAS,KAAyB,EAAE,QAA8B;;QAChE,OAAO,MAAA,IAAI,CAAC,KAAK,mCAAI,EAAE,CAAA;IACzB,CAAC;IAGH,kBAAC;AAAD,CAAC,AA5BD,CAA2H,yBAAW,GA4BrI;AA5BqB,kCAAW"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ItemContext, ItemLocator } from './ItemLocator';
|
|
2
2
|
import { Coordinates, MaterialItem } from '@gamepark/rules-api';
|
|
3
3
|
export declare abstract class PileLocator<P extends number = number, M extends number = number, L extends number = number> extends ItemLocator<P, M, L> {
|
|
4
4
|
limit: number;
|
|
5
5
|
rotate: boolean;
|
|
6
6
|
private positions;
|
|
7
7
|
private rotations;
|
|
8
|
-
getPosition(item: MaterialItem<P, L>, context:
|
|
9
|
-
getRotation(item: MaterialItem<P, L>, context:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
getPosition(item: MaterialItem<P, L>, context: ItemContext<P, M, L>): Coordinates;
|
|
9
|
+
getRotation(item: MaterialItem<P, L>, context: ItemContext<P, M, L>): number;
|
|
10
|
+
coordinates: Coordinates;
|
|
11
|
+
getCoordinates(_item: MaterialItem<P, L>, _context: ItemContext<P, M, L>): Coordinates;
|
|
12
|
+
radius: number;
|
|
13
|
+
getRadius(_item: MaterialItem<P, L>, _context: ItemContext<P, M, L>): number;
|
|
14
|
+
getPileId(item: MaterialItem<P, L>, _context: ItemContext<P, M, L>): number;
|
|
13
15
|
}
|
|
@@ -25,6 +25,8 @@ var PileLocator = /** @class */ (function (_super) {
|
|
|
25
25
|
_this.rotate = false;
|
|
26
26
|
_this.positions = new Map();
|
|
27
27
|
_this.rotations = new Map();
|
|
28
|
+
_this.coordinates = { x: 0, y: 0, z: 0 };
|
|
29
|
+
_this.radius = 0;
|
|
28
30
|
return _this;
|
|
29
31
|
}
|
|
30
32
|
PileLocator.prototype.getPosition = function (item, context) {
|
|
@@ -60,7 +62,17 @@ var PileLocator = /** @class */ (function (_super) {
|
|
|
60
62
|
}
|
|
61
63
|
return (_a = pileRotations.get(index)) !== null && _a !== void 0 ? _a : 0;
|
|
62
64
|
};
|
|
63
|
-
PileLocator.prototype.
|
|
65
|
+
PileLocator.prototype.getCoordinates = function (_item, _context) {
|
|
66
|
+
return this.coordinates;
|
|
67
|
+
};
|
|
68
|
+
PileLocator.prototype.getRadius = function (_item, _context) {
|
|
69
|
+
return this.radius;
|
|
70
|
+
};
|
|
71
|
+
PileLocator.prototype.getPileId = function (item, _context) {
|
|
72
|
+
if (typeof item.location.id === 'number')
|
|
73
|
+
return item.location.id;
|
|
74
|
+
if (item.location.player !== undefined)
|
|
75
|
+
return item.location.player;
|
|
64
76
|
return 0;
|
|
65
77
|
};
|
|
66
78
|
return PileLocator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PileLocator.js","sourceRoot":"","sources":["../../src/locators/PileLocator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"PileLocator.js","sourceRoot":"","sources":["../../src/locators/PileLocator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6CAAwD;AAGxD;IAA2H,+BAAoB;IAA/I;QAAA,qEAsDC;QArDC,WAAK,GAAG,EAAE,CAAA;QACV,YAAM,GAAG,KAAK,CAAA;QACN,e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AC,QAAQ,CAAC,EAAE,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAA;QACjE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAA;QACnE,OAAO,CAAC,CAAA;IACV,CAAC;IACH,kBAAC;AAAD,CAAC,AAtDD,CAA2H,yBAAW,GAsDrI;AAtDqB,kCAAW"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const animations: {
|
|
2
|
+
easeOut: (t: number) => number;
|
|
3
|
+
linear: (t: number) => number;
|
|
4
|
+
easeInQuad: (t: number) => number;
|
|
5
|
+
easeOutQuad: (t: number) => number;
|
|
6
|
+
easeInOutQuad: (t: number) => number;
|
|
7
|
+
easeInCubic: (t: number) => number;
|
|
8
|
+
easeOutCubic: (t: number) => number;
|
|
9
|
+
easeInOutCubic: (t: number) => number;
|
|
10
|
+
easeInQuart: (t: number) => number;
|
|
11
|
+
easeOutQuart: (t: number) => number;
|
|
12
|
+
easeInOutQuart: (t: number) => number;
|
|
13
|
+
easeInQuint: (t: number) => number;
|
|
14
|
+
easeOutQuint: (t: number) => number;
|
|
15
|
+
easeInOutQuint: (t: number) => number;
|
|
16
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.animations = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Comes from https://github.com/prc5/react-zoom-pan-pinch/blob/master/src/core/animations/animations.constants.ts
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Functions should return denominator of the target value, which is the next animation step.
|
|
9
|
+
* t is a value from 0 to 1, reflecting the percentage of animation status.
|
|
10
|
+
*/
|
|
11
|
+
var easeOut = function (t) {
|
|
12
|
+
return -Math.cos(t * Math.PI) / 2 + 0.5;
|
|
13
|
+
};
|
|
14
|
+
// linear
|
|
15
|
+
var linear = function (t) {
|
|
16
|
+
return t;
|
|
17
|
+
};
|
|
18
|
+
// accelerating from zero velocity
|
|
19
|
+
var easeInQuad = function (t) {
|
|
20
|
+
return t * t;
|
|
21
|
+
};
|
|
22
|
+
// decelerating to zero velocity
|
|
23
|
+
var easeOutQuad = function (t) {
|
|
24
|
+
return t * (2 - t);
|
|
25
|
+
};
|
|
26
|
+
// acceleration until halfway, then deceleration
|
|
27
|
+
var easeInOutQuad = function (t) {
|
|
28
|
+
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
|
|
29
|
+
};
|
|
30
|
+
// accelerating from zero velocity
|
|
31
|
+
var easeInCubic = function (t) {
|
|
32
|
+
return t * t * t;
|
|
33
|
+
};
|
|
34
|
+
// decelerating to zero velocity
|
|
35
|
+
var easeOutCubic = function (t) {
|
|
36
|
+
return --t * t * t + 1;
|
|
37
|
+
};
|
|
38
|
+
// acceleration until halfway, then deceleration
|
|
39
|
+
var easeInOutCubic = function (t) {
|
|
40
|
+
return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
|
|
41
|
+
};
|
|
42
|
+
// accelerating from zero velocity
|
|
43
|
+
var easeInQuart = function (t) {
|
|
44
|
+
return t * t * t * t;
|
|
45
|
+
};
|
|
46
|
+
// decelerating to zero velocity
|
|
47
|
+
var easeOutQuart = function (t) {
|
|
48
|
+
return 1 - --t * t * t * t;
|
|
49
|
+
};
|
|
50
|
+
// acceleration until halfway, then deceleration
|
|
51
|
+
var easeInOutQuart = function (t) {
|
|
52
|
+
return t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t;
|
|
53
|
+
};
|
|
54
|
+
// accelerating from zero velocity
|
|
55
|
+
var easeInQuint = function (t) {
|
|
56
|
+
return t * t * t * t * t;
|
|
57
|
+
};
|
|
58
|
+
// decelerating to zero velocity
|
|
59
|
+
var easeOutQuint = function (t) {
|
|
60
|
+
return 1 + --t * t * t * t * t;
|
|
61
|
+
};
|
|
62
|
+
// acceleration until halfway, then deceleration
|
|
63
|
+
var easeInOutQuint = function (t) {
|
|
64
|
+
return t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t;
|
|
65
|
+
};
|
|
66
|
+
exports.animations = {
|
|
67
|
+
easeOut: easeOut,
|
|
68
|
+
linear: linear,
|
|
69
|
+
easeInQuad: easeInQuad,
|
|
70
|
+
easeOutQuad: easeOutQuad,
|
|
71
|
+
easeInOutQuad: easeInOutQuad,
|
|
72
|
+
easeInCubic: easeInCubic,
|
|
73
|
+
easeOutCubic: easeOutCubic,
|
|
74
|
+
easeInOutCubic: easeInOutCubic,
|
|
75
|
+
easeInQuart: easeInQuart,
|
|
76
|
+
easeOutQuart: easeOutQuart,
|
|
77
|
+
easeInOutQuart: easeInOutQuart,
|
|
78
|
+
easeInQuint: easeInQuint,
|
|
79
|
+
easeOutQuint: easeOutQuint,
|
|
80
|
+
easeInOutQuint: easeInOutQuint
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=animations.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animations.constants.js","sourceRoot":"","sources":["../../src/utilities/animations.constants.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH;;;GAGG;AACH,IAAM,OAAO,GAAG,UAAC,CAAS;IACxB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;AACzC,CAAC,CAAA;AACD,SAAS;AACT,IAAM,MAAM,GAAG,UAAC,CAAS;IACvB,OAAO,CAAC,CAAA;AACV,CAAC,CAAA;AACD,kCAAkC;AAClC,IAAM,UAAU,GAAG,UAAC,CAAS;IAC3B,OAAO,CAAC,GAAG,CAAC,CAAA;AACd,CAAC,CAAA;AACD,gCAAgC;AAChC,IAAM,WAAW,GAAG,UAAC,CAAS;IAC5B,OAAO,CAAC,GAAG,CA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CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAC9D,CAAC,CAAA;AACD,kCAAkC;AAClC,IAAM,WAAW,GAAG,UAAC,CAAS;IAC5B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAC1B,CAAC,CAAA;AACD,gCAAgC;AAChC,IAAM,YAAY,GAAG,UAAU,CAAS;IACtC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAChC,CAAC,CAAA;AACD,gDAAgD;AAChD,IAAM,cAAc,GAAG,UAAU,CAAS;IACxC,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACxE,CAAC,CAAA;AAEY,QAAA,UAAU,GAAG;IACxB,OAAO,SAAA;IACP,MAAM,QAAA;IACN,UAAU,YAAA;IACV,WAAW,aAAA;IACX,aAAa,eAAA;IACb,WAAW,aAAA;IACX,YAAY,cAAA;IACZ,cAAc,gBAAA;IACd,WAAW,aAAA;IACX,YAAY,cAAA;IACZ,cAAc,gBAAA;IACd,WAAW,aAAA;IACX,YAAY,cAAA;IACZ,cAAc,gBAAA;CACf,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ReactZoomPanPinchContext, StateType } from 'react-zoom-pan-pinch';
|
|
2
|
+
export declare const handleCancelAnimation: (contextInstance: ReactZoomPanPinchContext) => void;
|
|
3
|
+
export declare function handleSetupAnimation(contextInstance: ReactZoomPanPinchContext, animationName: string, animationTime: number, callback: (step: number) => void): void;
|
|
4
|
+
export declare function animate(contextInstance: ReactZoomPanPinchContext, targetState: StateType, animationTime: number, animationName: string): void;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.animate = exports.handleSetupAnimation = exports.handleCancelAnimation = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Comes from https://github.com/prc5/react-zoom-pan-pinch/blob/master/src/core/animations/animations.utils.ts
|
|
6
|
+
*/
|
|
7
|
+
var animations_constants_1 = require("./animations.constants");
|
|
8
|
+
var handleCancelAnimationFrame = function (animation) {
|
|
9
|
+
if (typeof animation === 'number') {
|
|
10
|
+
cancelAnimationFrame(animation);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var handleCancelAnimation = function (contextInstance) {
|
|
14
|
+
if (!contextInstance.mounted)
|
|
15
|
+
return;
|
|
16
|
+
handleCancelAnimationFrame(contextInstance.animation);
|
|
17
|
+
// Clear animation state
|
|
18
|
+
contextInstance.animate = false;
|
|
19
|
+
contextInstance.animation = null;
|
|
20
|
+
contextInstance.velocity = null;
|
|
21
|
+
};
|
|
22
|
+
exports.handleCancelAnimation = handleCancelAnimation;
|
|
23
|
+
function handleSetupAnimation(contextInstance, animationName, animationTime, callback) {
|
|
24
|
+
if (!contextInstance.mounted)
|
|
25
|
+
return;
|
|
26
|
+
var startTime = new Date().getTime();
|
|
27
|
+
var lastStep = 1;
|
|
28
|
+
// if another animation is active
|
|
29
|
+
(0, exports.handleCancelAnimation)(contextInstance);
|
|
30
|
+
// new animation
|
|
31
|
+
contextInstance.animation = function () {
|
|
32
|
+
if (!contextInstance.mounted) {
|
|
33
|
+
return handleCancelAnimationFrame(contextInstance.animation);
|
|
34
|
+
}
|
|
35
|
+
var frameTime = new Date().getTime() - startTime;
|
|
36
|
+
var animationProgress = frameTime / animationTime;
|
|
37
|
+
var animationType = animations_constants_1.animations[animationName];
|
|
38
|
+
var step = animationType(animationProgress);
|
|
39
|
+
if (frameTime >= animationTime) {
|
|
40
|
+
callback(lastStep);
|
|
41
|
+
contextInstance.animation = null;
|
|
42
|
+
}
|
|
43
|
+
else if (contextInstance.animation) {
|
|
44
|
+
callback(step);
|
|
45
|
+
requestAnimationFrame(contextInstance.animation);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
requestAnimationFrame(contextInstance.animation);
|
|
49
|
+
}
|
|
50
|
+
exports.handleSetupAnimation = handleSetupAnimation;
|
|
51
|
+
function isValidTargetState(targetState) {
|
|
52
|
+
var scale = targetState.scale, positionX = targetState.positionX, positionY = targetState.positionY;
|
|
53
|
+
return !(Number.isNaN(scale) || Number.isNaN(positionX) || Number.isNaN(positionY));
|
|
54
|
+
}
|
|
55
|
+
function animate(contextInstance, targetState, animationTime, animationName) {
|
|
56
|
+
var isValid = isValidTargetState(targetState);
|
|
57
|
+
if (!contextInstance.mounted || !isValid)
|
|
58
|
+
return;
|
|
59
|
+
var setTransformState = contextInstance.setTransformState;
|
|
60
|
+
var _a = contextInstance.transformState, scale = _a.scale, positionX = _a.positionX, positionY = _a.positionY;
|
|
61
|
+
var scaleDiff = targetState.scale - scale;
|
|
62
|
+
var positionXDiff = targetState.positionX - positionX;
|
|
63
|
+
var positionYDiff = targetState.positionY - positionY;
|
|
64
|
+
if (animationTime === 0) {
|
|
65
|
+
setTransformState(targetState.scale, targetState.positionX, targetState.positionY);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// animation start timestamp
|
|
69
|
+
handleSetupAnimation(contextInstance, animationName, animationTime, function (step) {
|
|
70
|
+
var newScale = scale + scaleDiff * step;
|
|
71
|
+
var newPositionX = positionX + positionXDiff * step;
|
|
72
|
+
var newPositionY = positionY + positionYDiff * step;
|
|
73
|
+
setTransformState(newScale, newPositionX, newPositionY);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.animate = animate;
|
|
78
|
+
//# sourceMappingURL=animations.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animations.util.js","sourceRoot":"","sources":["../../src/utilities/animations.util.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,+DAAmD;AAGnD,IAAM,0BAA0B,GAAG,UAAC,SAA+B;IACjE,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;QACjC,oBAAoB,CAAC,SAAS,CAAC,CAAA;KAChC;AACH,CAAC,CAAA;AAEM,IAAM,qBAAqB,GAAG,UACnC,eAAyC;IAEzC,IAAI,CAAC,eAAe,CAAC,OAAO;QAAE,OAAM;IACpC,0BAA0B,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;IACrD,wBAAwB;IACxB,eAAe,CAAC,OAAO,GAAG,KAAK,CAAA;IAC/B,eAAe,CAAC,SAAS,GAAG,IAAI,CAAA;IAChC,eAAe,CAAC,QAAQ,GAAG,IAAI,CAAA;AACjC,CAAC,CAAA;AATY,QAAA,qBAAqB,yBASjC;AAED,SAAgB,oBAAoB,CAClC,eAAyC,EACzC,aAAqB,EACrB,aAAqB,EACrB,QAAgC;IAEhC,IAAI,CAAC,eAAe,CAAC,OAAO;QAAE,OAAM;IACpC,IAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;IACtC,IAAM,QAAQ,GAAG,CAAC,CAAA;IAElB,iCAAiC;IACjC,IAAA,6BAAqB,EAAC,eAAe,CAAC,CAAA;IAEtC,gBAAgB;IAChB,eAAe,CAAC,SAAS,GAAG;QAC1B,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE;YAC5B,OAAO,0BAA0B,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;SAC7D;QAED,IAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,SAAS,CAAA;QAClD,IAAM,iBAAiB,GAAG,SAAS,GAAG,aAAa,CAAA;QACnD,IAAM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IAAM,aAAa,GAAG,WAAW,CAAC,SAAS,GAAG,SAAS,CAAA;IAEvD,IAAI,aAAa,KAAK,CAAC,EAAE;QACvB,iBAAiB,CACf,WAAW,CAAC,KAAK,EACjB,WAAW,CAAC,SAAS,EACrB,WAAW,CAAC,SAAS,CACtB,CAAA;KACF;SAAM;QACL,4BAA4B;QAC5B,oBAAoB,CAClB,eAAe,EACf,aAAa,EACb,aAAa,EACb,UAAC,IAAY;YACX,IAAM,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,IAAI,CAAA;YACzC,IAAM,YAAY,GAAG,SAAS,GAAG,aAAa,GAAG,IAAI,CAAA;YACrD,IAAM,YAAY,GAAG,SAAS,GAAG,aAAa,GAAG,IAAI,CAAA;YAErD,iBAAiB,CAAC,QAAQ,EAAE,YAAY,EAAE,YAAY,CAAC,CAAA;QACzD,CAAC,CACF,CAAA;KACF;AACH,CAAC;AArCD,0BAqCC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comes from https://github.com/prc5/react-zoom-pan-pinch/blob/master/src/utils/calculations.utils.ts
|
|
3
|
+
*/
|
|
4
|
+
import { BoundsType, PositionType, ReactZoomPanPinchContext } from 'react-zoom-pan-pinch';
|
|
5
|
+
import { ComponentsSizesType } from 'react-zoom-pan-pinch/dist/src/core/bounds/bounds.types';
|
|
6
|
+
export declare function getComponentsSizes(wrapperComponent: HTMLDivElement, contentComponent: HTMLDivElement, newScale: number): ComponentsSizesType;
|
|
7
|
+
export declare const getBounds: (wrapperWidth: number, newContentWidth: number, diffWidth: number, wrapperHeight: number, newContentHeight: number, diffHeight: number, centerZoomedOut: boolean) => BoundsType;
|
|
8
|
+
export declare const calculateBounds: (contextInstance: ReactZoomPanPinchContext, newScale: number) => BoundsType;
|
|
9
|
+
/**
|
|
10
|
+
* Keeps value between given bounds, used for limiting view to given boundaries
|
|
11
|
+
* 1# eg. boundLimiter(2, 0, 3, true) => 2
|
|
12
|
+
* 2# eg. boundLimiter(4, 0, 3, true) => 3
|
|
13
|
+
* 3# eg. boundLimiter(-2, 0, 3, true) => 0
|
|
14
|
+
* 4# eg. boundLimiter(10, 0, 3, false) => 10
|
|
15
|
+
*/
|
|
16
|
+
export declare const boundLimiter: (value: number, minBound: number, maxBound: number, isActive: boolean) => number;
|
|
17
|
+
export declare const handleCalculateBounds: (contextInstance: ReactZoomPanPinchContext, newScale: number) => BoundsType;
|
|
18
|
+
export declare function getMouseBoundedPosition(positionX: number, positionY: number, bounds: BoundsType, limitToBounds: boolean, paddingValueX: number, paddingValueY: number, wrapperComponent: HTMLDivElement | null): PositionType;
|