@khanacademy/math-input 0.7.2 → 1.0.1
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/CHANGELOG.md +16 -0
- package/dist/components/compute-layout-parameters.d.ts +38 -0
- package/dist/components/compute-layout-parameters.js.flow +49 -0
- package/dist/components/corner-decal.d.ts +12 -0
- package/dist/components/corner-decal.js.flow +15 -0
- package/dist/components/echo-manager.d.ts +26 -0
- package/dist/components/echo-manager.js.flow +29 -0
- package/dist/components/empty-keypad-button.d.ts +13 -0
- package/dist/components/empty-keypad-button.js.flow +23 -0
- package/dist/components/expression-keypad.d.ts +22 -0
- package/dist/components/expression-keypad.js.flow +32 -0
- package/dist/components/fraction-keypad.d.ts +21 -0
- package/dist/components/fraction-keypad.js.flow +30 -0
- package/dist/components/gesture-manager.d.ts +74 -0
- package/dist/components/gesture-manager.js.flow +82 -0
- package/dist/components/gesture-state-machine.d.ts +105 -0
- package/dist/components/gesture-state-machine.js.flow +118 -0
- package/dist/components/icon.d.ts +15 -0
- package/dist/components/icon.js.flow +18 -0
- package/dist/components/input/__tests__/test-math-wrapper.d.ts +8 -0
- package/dist/components/input/__tests__/test-math-wrapper.js.flow +14 -0
- package/dist/components/input/cursor-handle.d.ts +1 -1
- package/dist/components/input/cursor-handle.js.flow +1 -1
- package/dist/components/input/drag-listener.d.ts +13 -0
- package/dist/components/input/drag-listener.js.flow +19 -0
- package/dist/components/input/math-input.d.ts +5 -4
- package/dist/components/input/math-input.js.flow +5 -4
- package/dist/components/input/math-wrapper.d.ts +110 -0
- package/dist/components/input/math-wrapper.js.flow +125 -0
- package/dist/components/input/scroll-into-view.d.ts +11 -0
- package/dist/components/input/scroll-into-view.js.flow +20 -0
- package/dist/components/keypad/button-assets.d.ts +4 -3
- package/dist/components/keypad/button-assets.js.flow +3 -3
- package/dist/components/keypad/button.d.ts +1 -2
- package/dist/components/keypad/button.js.flow +1 -2
- package/dist/components/keypad/index.d.ts +1 -1
- package/dist/components/keypad/index.js.flow +1 -3
- package/dist/components/keypad/keypad-page-items.d.ts +15 -10
- package/dist/components/keypad/keypad-page-items.js.flow +20 -10
- package/dist/components/keypad-button.d.ts +52 -0
- package/dist/components/keypad-button.js.flow +79 -0
- package/dist/components/keypad-container.d.ts +40 -0
- package/dist/components/keypad-container.js.flow +58 -0
- package/dist/components/keypad.d.ts +31 -0
- package/dist/components/keypad.js.flow +40 -0
- package/dist/components/many-keypad-button.d.ts +15 -0
- package/dist/components/many-keypad-button.js.flow +17 -0
- package/dist/components/math-icon.d.ts +16 -0
- package/dist/components/math-icon.js.flow +19 -0
- package/dist/components/multi-symbol-grid.d.ts +14 -0
- package/dist/components/multi-symbol-grid.js.flow +16 -0
- package/dist/components/multi-symbol-popover.d.ts +12 -0
- package/dist/components/multi-symbol-popover.js.flow +15 -0
- package/dist/components/navigation-pad.d.ts +14 -0
- package/dist/components/navigation-pad.js.flow +16 -0
- package/dist/components/node-manager.d.ts +50 -0
- package/dist/components/node-manager.js.flow +62 -0
- package/dist/components/popover-manager.d.ts +13 -0
- package/dist/components/popover-manager.js.flow +15 -0
- package/dist/components/popover-state-machine.d.ts +68 -0
- package/dist/components/popover-state-machine.js.flow +77 -0
- package/dist/components/provided-keypad.d.ts +8 -10
- package/dist/components/provided-keypad.js.flow +8 -10
- package/dist/components/styles.d.ts +6 -0
- package/dist/components/styles.js.flow +13 -0
- package/dist/components/svg-icon.d.ts +12 -0
- package/dist/components/svg-icon.js.flow +15 -0
- package/dist/components/tabbar/icons.d.ts +3 -2
- package/dist/components/tabbar/icons.js.flow +3 -2
- package/dist/components/tabbar/item.d.ts +1 -2
- package/dist/components/tabbar/item.js.flow +1 -2
- package/dist/components/tabbar/tabbar.d.ts +3 -3
- package/dist/components/tabbar/tabbar.js.flow +3 -3
- package/dist/components/text-icon.d.ts +13 -0
- package/dist/components/text-icon.js.flow +16 -0
- package/dist/components/touchable-keypad-button.d.ts +30 -0
- package/dist/components/touchable-keypad-button.js.flow +35 -0
- package/dist/components/two-page-keypad.d.ts +20 -0
- package/dist/components/two-page-keypad.js.flow +30 -0
- package/dist/components/velocity-tracker.d.ts +48 -0
- package/dist/components/velocity-tracker.js.flow +54 -0
- package/dist/es/index.css +0 -3
- package/dist/es/index.js +933 -1065
- package/dist/es/index.js.map +1 -1
- package/dist/fake-react-native-web/text.d.ts +2 -1
- package/dist/fake-react-native-web/text.js.flow +2 -1
- package/dist/fake-react-native-web/view.d.ts +3 -2
- package/dist/fake-react-native-web/view.js.flow +3 -2
- package/dist/index.css +0 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +977 -1090
- package/dist/index.js.flow +1 -4
- package/dist/index.js.map +1 -1
- package/dist/store/actions.d.ts +64 -0
- package/dist/store/actions.js.flow +100 -0
- package/dist/store/echo-reducer.d.ts +4 -0
- package/dist/store/echo-reducer.js.flow +10 -0
- package/dist/store/index.d.ts +10 -1
- package/dist/store/index.js.flow +17 -1
- package/dist/store/input-reducer.d.ts +4 -0
- package/dist/store/input-reducer.js.flow +13 -0
- package/dist/store/keypad-reducer.d.ts +4 -0
- package/dist/store/keypad-reducer.js.flow +13 -0
- package/dist/store/layout-reducer.d.ts +4 -0
- package/dist/store/layout-reducer.js.flow +13 -0
- package/dist/store/pager-reducer.d.ts +4 -0
- package/dist/store/pager-reducer.js.flow +13 -0
- package/dist/store/shared.d.ts +6 -0
- package/dist/store/shared.js.flow +13 -0
- package/dist/store/types.d.ts +58 -0
- package/dist/store/types.js.flow +64 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.js.flow +73 -0
- package/less/overrides.less +0 -6
- package/package.json +1 -1
- package/src/components/__tests__/{gesture-state-machine_test.js → gesture-state-machine.test.ts} +5 -1
- package/src/components/__tests__/{two-page-keypad_test.js → two-page-keypad.test.tsx} +0 -2
- package/src/components/{corner-decal.js → corner-decal.tsx} +6 -5
- package/src/components/{echo-manager.js → echo-manager.tsx} +29 -24
- package/src/components/{empty-keypad-button.js → empty-keypad-button.tsx} +17 -10
- package/src/components/{expression-keypad.js → expression-keypad.tsx} +27 -25
- package/src/components/{fraction-keypad.js → fraction-keypad.tsx} +21 -16
- package/src/components/{gesture-manager.js → gesture-manager.ts} +10 -4
- package/src/components/{gesture-state-machine.js → gesture-state-machine.ts} +49 -3
- package/src/components/{icon.js → icon.tsx} +12 -14
- package/src/components/input/cursor-handle.tsx +1 -1
- package/src/components/input/{drag-listener.js → drag-listener.ts} +4 -0
- package/src/components/input/math-input.tsx +10 -9
- package/src/components/input/{math-wrapper.js → math-wrapper.ts} +10 -6
- package/src/components/input/{scroll-into-view.js → scroll-into-view.ts} +5 -15
- package/src/components/keypad/button-assets.tsx +4 -5
- package/src/components/keypad/button.tsx +1 -2
- package/src/components/keypad/index.tsx +2 -2
- package/src/components/keypad/keypad-page-items.tsx +33 -10
- package/src/components/{keypad-button.js → keypad-button.tsx} +42 -37
- package/src/components/{keypad-container.js → keypad-container.tsx} +42 -24
- package/src/components/{keypad.js → keypad.tsx} +32 -24
- package/src/components/{many-keypad-button.js → many-keypad-button.tsx} +8 -6
- package/src/components/{math-icon.js → math-icon.tsx} +7 -6
- package/src/components/{multi-symbol-grid.js → multi-symbol-grid.tsx} +8 -8
- package/src/components/{multi-symbol-popover.js → multi-symbol-popover.tsx} +5 -6
- package/src/components/{navigation-pad.js → navigation-pad.tsx} +7 -6
- package/src/components/{node-manager.js → node-manager.ts} +16 -4
- package/src/components/{popover-manager.js → popover-manager.tsx} +13 -16
- package/src/components/{popover-state-machine.js → popover-state-machine.ts} +13 -2
- package/src/components/prop-types.js +1 -67
- package/src/components/provided-keypad.tsx +16 -23
- package/src/components/{svg-icon.js → svg-icon.tsx} +5 -6
- package/src/components/tabbar/icons.tsx +4 -2
- package/src/components/tabbar/item.tsx +1 -3
- package/src/components/tabbar/{tabbar.stories.js → tabbar.stories.tsx} +10 -1
- package/src/components/tabbar/tabbar.tsx +3 -3
- package/src/components/{text-icon.js → text-icon.tsx} +7 -6
- package/src/components/{touchable-keypad-button.js → touchable-keypad-button.tsx} +19 -16
- package/src/components/{two-page-keypad.js → two-page-keypad.tsx} +13 -9
- package/src/components/{velocity-tracker.js → velocity-tracker.ts} +14 -4
- package/src/fake-react-native-web/text.tsx +2 -1
- package/src/fake-react-native-web/view.tsx +3 -2
- package/src/index.ts +1 -4
- package/src/math-input.stories.tsx +67 -0
- package/src/store/actions.ts +178 -0
- package/src/store/echo-reducer.ts +61 -0
- package/src/store/index.ts +39 -449
- package/src/store/input-reducer.ts +56 -0
- package/src/store/keypad-reducer.ts +59 -0
- package/src/store/layout-reducer.ts +134 -0
- package/src/store/pager-reducer.ts +125 -0
- package/src/store/shared.ts +12 -0
- package/src/store/types.ts +82 -0
- package/src/types.ts +81 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/actions/index.js +0 -57
- package/src/components/app.js +0 -73
- package/src/demo.js +0 -9
- package/src/native-app.js +0 -85
- /package/src/components/__tests__/{node-manager_test.js → node-manager.test.ts} +0 -0
- /package/src/components/{compute-layout-parameters.js → compute-layout-parameters.ts} +0 -0
- /package/src/components/input/__tests__/{context-tracking_test.js → context-tracking.test.ts} +0 -0
- /package/src/components/input/__tests__/{mathquill_test.js → mathquill.test.ts} +0 -0
- /package/src/components/input/__tests__/{test-math-wrapper.jsx → test-math-wrapper.ts} +0 -0
- /package/src/components/keypad/{button.stories.js → button.stories.tsx} +0 -0
- /package/src/components/{styles.js → styles.ts} +0 -0
- /package/src/components/tabbar/__tests__/{tabbar_test.js → tabbar.test.tsx} +0 -0
package/src/index.ts
CHANGED
|
@@ -5,10 +5,7 @@
|
|
|
5
5
|
import "../less/main.less";
|
|
6
6
|
|
|
7
7
|
export {default as KeypadInput} from "./components/input/math-input";
|
|
8
|
-
export {
|
|
9
|
-
keypadConfigurationPropType,
|
|
10
|
-
keypadElementPropType,
|
|
11
|
-
} from "./components/prop-types";
|
|
8
|
+
export {keypadElementPropType} from "./components/prop-types";
|
|
12
9
|
export {default as Keypad} from "./components/provided-keypad";
|
|
13
10
|
export {KeypadTypes} from "./consts";
|
|
14
11
|
export {default as KeyConfigs} from "./data/key-configs";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import {Keypad, KeypadInput, KeypadTypes} from "./index";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "Full MathInput",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Basic = () => {
|
|
10
|
+
const [value, setValue] = React.useState("");
|
|
11
|
+
const [keypadElement, setKeypadElement] = React.useState<any>(null);
|
|
12
|
+
const [keypadType, setKeypadType] = React.useState<
|
|
13
|
+
keyof typeof KeypadTypes
|
|
14
|
+
>(KeypadTypes.FRACTION);
|
|
15
|
+
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
keypadElement?.configure({
|
|
18
|
+
keypadType: keypadType,
|
|
19
|
+
extraKeys: ["x", "y", "PI", "THETA"],
|
|
20
|
+
});
|
|
21
|
+
}, [keypadElement, keypadType]);
|
|
22
|
+
|
|
23
|
+
function handleChangeKeypadType() {
|
|
24
|
+
setKeypadType(
|
|
25
|
+
keypadType === KeypadTypes.FRACTION
|
|
26
|
+
? KeypadTypes.EXPRESSION
|
|
27
|
+
: KeypadTypes.FRACTION,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div>
|
|
33
|
+
<div style={{padding: "1rem 0"}}>
|
|
34
|
+
<button onClick={handleChangeKeypadType}>
|
|
35
|
+
{`Use ${
|
|
36
|
+
keypadType === KeypadTypes.FRACTION
|
|
37
|
+
? "Expression"
|
|
38
|
+
: "Fraction"
|
|
39
|
+
} Keypad`}
|
|
40
|
+
</button>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<KeypadInput
|
|
44
|
+
value={value}
|
|
45
|
+
keypadElement={keypadElement}
|
|
46
|
+
onChange={(newValue, callback) => {
|
|
47
|
+
setValue(newValue);
|
|
48
|
+
callback();
|
|
49
|
+
}}
|
|
50
|
+
onFocus={() => {
|
|
51
|
+
keypadElement?.activate();
|
|
52
|
+
}}
|
|
53
|
+
onBlur={() => {
|
|
54
|
+
keypadElement?.dismiss();
|
|
55
|
+
}}
|
|
56
|
+
/>
|
|
57
|
+
|
|
58
|
+
<Keypad
|
|
59
|
+
onElementMounted={(node) => {
|
|
60
|
+
if (node && !keypadElement) {
|
|
61
|
+
setKeypadElement(node);
|
|
62
|
+
}
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type {Key} from "../data/keys";
|
|
2
|
+
import type {
|
|
3
|
+
KeypadConfiguration,
|
|
4
|
+
KeyHandler,
|
|
5
|
+
Cursor,
|
|
6
|
+
ActiveNodesObj,
|
|
7
|
+
Border,
|
|
8
|
+
} from "../types";
|
|
9
|
+
|
|
10
|
+
// naming convention: verb + noun
|
|
11
|
+
// the noun should be one of the other properties in the object that's
|
|
12
|
+
// being dispatched
|
|
13
|
+
|
|
14
|
+
type DismissKeypadAction = {
|
|
15
|
+
type: "DismissKeypad";
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const dismissKeypad = (): DismissKeypadAction => {
|
|
19
|
+
return {
|
|
20
|
+
type: "DismissKeypad",
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type ActivateKeypadAction = {
|
|
25
|
+
type: "ActivateKeypad";
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const activateKeypad = (): ActivateKeypadAction => {
|
|
29
|
+
return {
|
|
30
|
+
type: "ActivateKeypad",
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Configure the keypad with the provided configuration parameters.
|
|
36
|
+
*/
|
|
37
|
+
type ConfigureKeypadAction = {
|
|
38
|
+
type: "ConfigureKeypad";
|
|
39
|
+
configuration: KeypadConfiguration;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const configureKeypad = (
|
|
43
|
+
configuration: KeypadConfiguration,
|
|
44
|
+
): ConfigureKeypadAction => {
|
|
45
|
+
return {
|
|
46
|
+
type: "ConfigureKeypad",
|
|
47
|
+
configuration,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type SetPageSizeAction = {
|
|
52
|
+
type: "SetPageSize";
|
|
53
|
+
pageWidthPx: number;
|
|
54
|
+
pageHeightPx: number;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const setPageSize = (
|
|
58
|
+
pageWidthPx: number,
|
|
59
|
+
pageHeightPx: number,
|
|
60
|
+
): SetPageSizeAction => {
|
|
61
|
+
return {
|
|
62
|
+
type: "SetPageSize",
|
|
63
|
+
pageWidthPx,
|
|
64
|
+
pageHeightPx,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
type RemoveEchoAction = {
|
|
69
|
+
type: "RemoveEcho";
|
|
70
|
+
animationId: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const removeEcho = (animationId: string): RemoveEchoAction => {
|
|
74
|
+
return {
|
|
75
|
+
type: "RemoveEcho",
|
|
76
|
+
animationId,
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Input-related actions.
|
|
81
|
+
type SetKeyHandlerAction = {
|
|
82
|
+
type: "SetKeyHandler";
|
|
83
|
+
keyHandler: KeyHandler;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const setKeyHandler = (keyHandler: KeyHandler): SetKeyHandlerAction => {
|
|
87
|
+
return {
|
|
88
|
+
type: "SetKeyHandler",
|
|
89
|
+
keyHandler,
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
type SetCursorAction = {
|
|
94
|
+
type: "SetCursor";
|
|
95
|
+
cursor: Cursor;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const setCursor = (cursor: Cursor): SetCursorAction => {
|
|
99
|
+
return {
|
|
100
|
+
type: "SetCursor",
|
|
101
|
+
cursor,
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Gesture actions
|
|
106
|
+
type OnSwipeChangeAction = {
|
|
107
|
+
type: "OnSwipeChange";
|
|
108
|
+
dx: number;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const onSwipeChange = (dx: number): OnSwipeChangeAction => {
|
|
112
|
+
return {
|
|
113
|
+
type: "OnSwipeChange",
|
|
114
|
+
dx,
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
type OnSwipeEndAction = {
|
|
119
|
+
type: "OnSwipeEnd";
|
|
120
|
+
dx: number;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const onSwipeEnd = (dx: number): OnSwipeEndAction => {
|
|
124
|
+
return {
|
|
125
|
+
type: "OnSwipeEnd",
|
|
126
|
+
dx,
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
type SetActiveNodesAction = {
|
|
131
|
+
type: "SetActiveNodes";
|
|
132
|
+
activeNodes: any;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const setActiveNodes = (
|
|
136
|
+
activeNodes: ActiveNodesObj,
|
|
137
|
+
): SetActiveNodesAction => {
|
|
138
|
+
return {
|
|
139
|
+
type: "SetActiveNodes",
|
|
140
|
+
activeNodes,
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
type PressKeyAction = {
|
|
145
|
+
type: "PressKey";
|
|
146
|
+
key: Key;
|
|
147
|
+
borders: Border;
|
|
148
|
+
initialBounds: DOMRect;
|
|
149
|
+
inPopover: boolean;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const pressKey = (
|
|
153
|
+
key: Key,
|
|
154
|
+
borders: Border,
|
|
155
|
+
initialBounds: DOMRect,
|
|
156
|
+
inPopover: any,
|
|
157
|
+
): PressKeyAction => {
|
|
158
|
+
return {
|
|
159
|
+
type: "PressKey",
|
|
160
|
+
key,
|
|
161
|
+
borders,
|
|
162
|
+
initialBounds,
|
|
163
|
+
inPopover,
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export type Action =
|
|
168
|
+
| DismissKeypadAction
|
|
169
|
+
| ActivateKeypadAction
|
|
170
|
+
| ConfigureKeypadAction
|
|
171
|
+
| SetPageSizeAction
|
|
172
|
+
| RemoveEchoAction
|
|
173
|
+
| SetKeyHandlerAction
|
|
174
|
+
| SetCursorAction
|
|
175
|
+
| OnSwipeChangeAction
|
|
176
|
+
| OnSwipeEndAction
|
|
177
|
+
| SetActiveNodesAction
|
|
178
|
+
| PressKeyAction;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {EchoAnimationTypes, KeyTypes} from "../consts";
|
|
2
|
+
import KeyConfigs from "../data/key-configs";
|
|
3
|
+
|
|
4
|
+
import type {Action} from "./actions";
|
|
5
|
+
import type {EchoState} from "./types";
|
|
6
|
+
|
|
7
|
+
// Used to generate unique animation IDs for the echo animations. The actual
|
|
8
|
+
// values are irrelevant as long as they are unique.
|
|
9
|
+
let _lastAnimationId = 0;
|
|
10
|
+
|
|
11
|
+
const initialEchoState = {
|
|
12
|
+
echoes: [],
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
const echoReducer = function (
|
|
16
|
+
state: EchoState = initialEchoState,
|
|
17
|
+
action: Action,
|
|
18
|
+
): EchoState {
|
|
19
|
+
switch (action.type) {
|
|
20
|
+
case "PressKey":
|
|
21
|
+
const keyConfig = KeyConfigs[action.key];
|
|
22
|
+
|
|
23
|
+
// Add in the echo animation if the user performs a math
|
|
24
|
+
// operation.
|
|
25
|
+
if (
|
|
26
|
+
keyConfig.type === KeyTypes.VALUE ||
|
|
27
|
+
keyConfig.type === KeyTypes.OPERATOR
|
|
28
|
+
) {
|
|
29
|
+
return {
|
|
30
|
+
...state,
|
|
31
|
+
echoes: [
|
|
32
|
+
...state.echoes,
|
|
33
|
+
{
|
|
34
|
+
animationId: "" + _lastAnimationId++,
|
|
35
|
+
animationType: action.inPopover
|
|
36
|
+
? EchoAnimationTypes.LONG_FADE_ONLY
|
|
37
|
+
: EchoAnimationTypes.FADE_ONLY,
|
|
38
|
+
borders: action.borders,
|
|
39
|
+
id: keyConfig.id,
|
|
40
|
+
initialBounds: action.initialBounds,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return state;
|
|
46
|
+
|
|
47
|
+
case "RemoveEcho":
|
|
48
|
+
const remainingEchoes = state.echoes.filter((echo) => {
|
|
49
|
+
return echo.animationId !== action.animationId;
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
...state,
|
|
53
|
+
echoes: remainingEchoes,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
default:
|
|
57
|
+
return state;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default echoReducer;
|