Skip to content

Commit 1851889

Browse files
committed
curve-editor: implement pool
1 parent 641e345 commit 1851889

14 files changed

+326
-164
lines changed

app/build/mojs-curve-editor.js

Lines changed: 227 additions & 130 deletions
Large diffs are not rendered by default.

app/build/mojs-curve-editor.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/css/blocks/curve-editor.postcss.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@
113113
height .15s ease-out,
114114
border-radius .15s ease-out;
115115
}*/
116+
117+
&.is-inactive {
118+
.curve-editor__mojs-logo {
119+
& [data-component="icon"] {
120+
fill: $c-pastel-purple;
121+
}
122+
}
123+
}
116124

117125
&.is-minimized {
118126
width: calc(100*$PX) !important;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"curve-editor":"_curve-editor_1v48l_3","curve-editor__left":"_curve-editor__left_1v48l_1","curve-editor__right":"_curve-editor__right_1v48l_132","curve-editor__resize-handle":"_curve-editor__resize-handle_1v48l_1","curve-editor__anchor-buttons":"_curve-editor__anchor-buttons_1v48l_127","curve-editor__mojs-logo":"_curve-editor__mojs-logo_1v48l_128","is-minimized":"_is-minimized_1v48l_117","curve__svg-wrapper":"_curve__svg-wrapper_1v48l_136"}
1+
{"curve-editor":"_curve-editor_12556_3","curve-editor__left":"_curve-editor__left_12556_1","curve-editor__right":"_curve-editor__right_12556_140","curve-editor__resize-handle":"_curve-editor__resize-handle_12556_1","curve-editor__anchor-buttons":"_curve-editor__anchor-buttons_12556_135","curve-editor__mojs-logo":"_curve-editor__mojs-logo_12556_118","is-inactive":"_is-inactive_12556_117","is-minimized":"_is-minimized_12556_125","curve__svg-wrapper":"_curve__svg-wrapper_12556_144"}

app/js/app.babel.jsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class API {
2424
this._listenUnload();
2525

2626
this._subscribe();
27-
this._subscribeFocus();
27+
// this._subscribeFocus();
2828
}
2929

3030
_decalareDefaults ( ) {
@@ -43,7 +43,7 @@ class API {
4343
}
4444

4545
_vars () {
46-
this.revision = '1.3.0';
46+
this.revision = '1.4.0';
4747
this.store = initStore();
4848

4949
this._easings = [];
@@ -60,7 +60,8 @@ class API {
6060
document.addEventListener('DOMContentLoaded', () => {
6161
render(
6262
<Provider store={this.store}>
63-
<CurveEditor progressLines={this._progressLines} />
63+
<CurveEditor progressLines = {this._progressLines}
64+
ref={ (el) => { this._el = el; }} />
6465
</Provider>, document.body);
6566
});
6667
}
@@ -93,13 +94,13 @@ class API {
9394
this.store.subscribe( this._compilePath.bind(this) );
9495
}
9596

96-
_subscribeFocus () {
97-
addPointerDown( document.body, (e) => {
98-
if (this._localStorage !== e._mojsCurveEditorName) {
99-
this.store.dispatch({ type: 'POINT_DESELECT_ALL' });
100-
}
101-
});
102-
}
97+
// _subscribeFocus () {
98+
// addPointerDown( document.body, (e) => {
99+
// if (this._localStorage !== e._mojsCurveEditorName) {
100+
// this.store.dispatch({ type: 'POINT_DESELECT_ALL' });
101+
// }
102+
// });
103+
// }
103104

104105
_compilePath () {
105106

@@ -150,7 +151,6 @@ class API {
150151
updateProgress = (progress + step < 1 )
151152
? (progress + step) : (progress - step);
152153

153-
// console.log(updateProgress, progress);
154154
parent.setProgress( updateProgress );
155155
parent.setProgress( progress );
156156
}

app/js/constants.babel.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ export default {
44
CURVE_SIZE,
55
RESIZE_NEGATIVE_OFFSET: 150,
66
CURVE_PERCENT: CURVE_SIZE/100,
7-
CURVE_PADDING: 10
7+
CURVE_PADDING: 10,
8+
ACTIVE_POOL_NAME: '_mojsCurveEditorPool'
89
}

app/js/helpers/active-pool.babel.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class ActivePool {
2+
constructor () {
3+
this._subscribers = [];
4+
}
5+
6+
add (fn) { this._subscribers.push(fn); }
7+
8+
resetActive (name) {
9+
for (let i = 0; i < this._subscribers.length; i++) {
10+
this._subscribers[i](name);
11+
}
12+
}
13+
}
14+
15+
export default ActivePool;

app/js/pool.babel.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ class Pool {
44
}
55
push (states) {
66
// this._states.push(states);
7-
// console.log(this._states.length);
87
return this;
98
}
109

app/js/reducers/controls-reducer.babel.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import calculatePath from '../helpers/calculate-path';
22
import pool from '../pool';
33

4-
const INITIAL_STATE = { isCode: false, isMinimize: false }
4+
const INITIAL_STATE = {
5+
isCode: false,
6+
isMinimize: false,
7+
isActive: false
8+
}
59

610
const controls = (state = INITIAL_STATE, action) => {
711
pool.push( state );
@@ -12,8 +16,11 @@ const controls = (state = INITIAL_STATE, action) => {
1216
case 'SET_MINIMIZE': {
1317
return { ...state, isMinimize: action.data };
1418
}
15-
case 'RESET_MINIMIZE_TRANISTION': {
16-
return { ...state, isTransition: false };
19+
// case 'RESET_MINIMIZE_TRANISTION': {
20+
// return { ...state, isTransition: false };
21+
// }
22+
case 'SET_ACTIVE': {
23+
return { ...state, isActive: action.data };
1724
}
1825
}
1926
return state;

app/js/reducers/points-reducer.babel.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ const pointsReducer = (state = INITIAL_STATE, action) => {
135135
return { ...deselectAll( state ) };
136136
}
137137

138+
case 'SET_ACTIVE': {
139+
return (!action.data) ? { ...deselectAll( state ) } : state;
140+
}
141+
138142
// HANDLES
139143
case 'HANDLE_TRANSLATE': {
140144
const {points} = state,

0 commit comments

Comments
 (0)