Skip to content

Commit fdbd787

Browse files
committed
remove riotjs tags
1 parent d6407d2 commit fdbd787

31 files changed

+1857
-2474
lines changed

app/build/mojs-curve-editor.js

Lines changed: 1746 additions & 1660 deletions
Large diffs are not rendered by default.

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

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/js/app.babel.jsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ import defer from './helpers/defer';
1111
import addPointerDown from './helpers/add-pointer-down';
1212

1313
// TODO
14-
// - resize down when points are above the editor border
15-
// - add points shortcuts
16-
// - performance
1714
// - import path data
1815
// - move bunch of points at once
16+
// - add period generator
1917

2018
/*
2119
API wrapper above the app itself.
@@ -117,15 +115,21 @@ class API {
117115
}
118116

119117
_compilePath () {
118+
120119
const state = this.store.getState(),
121120
points = state.points.present,
122121
{path} = points;
123122

124-
if ( this._prevPath !== path ) {
125-
this._prevPath = path;
126-
this._easing = mojs.easing.path( path );
127-
this._fireOnChange( path );
128-
}
123+
if ( !this._easing ) { this._easing = mojs.easing.path( path ); }
124+
125+
clearTimeout( this._tm );
126+
this._tm = setTimeout( () => {
127+
if ( this._prevPath !== path ) {
128+
this._prevPath = path;
129+
this._easing = mojs.easing.path( path );
130+
this._fireOnChange( path );
131+
}
132+
}, 40 );
129133
}
130134

131135
_fireOnChange ( path ) {

app/js/helpers/debounce.babel.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
export default (fn, time = 25) => {
3+
let tm = null;
4+
return () => {
5+
clearTimeout( tm );
6+
setTimeout( fn, time );
7+
}
8+
}

app/js/helpers/mod-deltas.babel.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import mod from './resize-mod';
2+
3+
export default (x, y, type, state) => {
4+
const {resize} = state;
5+
// get modulus size for `top` and `bottom` types
6+
if ( type !== 'right' ) {
7+
const size = resize[type] + y,
8+
coef = ( type === 'top' ) ? -1 : 1;
9+
// normalize the y delta to modulus of CURVE_SIZEs
10+
y = mod( size, coef );
11+
y -= resize[type];
12+
// ensure size won't be less then CURVE_SIZE
13+
if ( size*coef < 0 ) { y = -resize[type]; }
14+
// ensure size won't be less then CURVE_SIZE
15+
} else if ( resize[type] + x < 0 ) { x = -resize[type]; }
16+
17+
return { x, y, type, resize };
18+
}

app/js/helpers/resize-mod.babel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const mod = ( tempResize_top, coef = 1 ) => {
99
GAP = 15;
1010

1111
if (MOD < GAP ) { tempResize_top = DIV*Y_SIZE; }
12-
else if ( MOD > Y_SIZE - GAP ) { tempResize_top = coef*(DIV+1)*Y_SIZE; }
12+
else if ( MOD > Y_SIZE - GAP ) { tempResize_top = (DIV+(1*coef))*Y_SIZE; }
1313

1414
return tempResize_top;
1515
}

app/js/pool.babel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default [];

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

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

3-
const INITIAL_STATE = {
4-
isCode: false
5-
}
4+
const INITIAL_STATE = { isCode: false }
65

76
const controls = (state = INITIAL_STATE, action) => {
7+
pool.push( state );
88
switch (action.type) {
99
case 'CODE_TAP': {
1010
return { ...state, isCode: !state.isCode };

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const INITIAL_STATE = {
32
isShow: false,
43
type: 'straight'

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,34 @@ const pointsReducer = (state = INITIAL_STATE, action) => {
177177
}
178178

179179
case 'HANDLE_TRANSLATE_END': {
180-
return state;//{ ...state };
180+
return state;
181+
}
182+
183+
case 'EDITOR_RESIZE': {
184+
const {data} = action,
185+
points = [...state.points],
186+
{type, resize} = data;
187+
188+
// return state if resize to the `right`
189+
if (type === 'right') { return state; }
190+
191+
// normalize points' y regarding resize
192+
if ( type === 'top' ) {
193+
for (var i = 0; i < points.length; i++) {
194+
const borderTop = Math.min(resize.top + data.y, 0),
195+
point = points[i];
196+
if (point.y < borderTop) { point.y = borderTop; }
197+
}
198+
} else if ( type === 'bottom' ) {
199+
for (var i = 0; i < points.length; i++) {
200+
const borderBottom = Math.max(resize.bottom + data.y, 0) + C.CURVE_SIZE,
201+
point = points[i];
202+
203+
if (point.y > borderBottom) { point.y = borderBottom; }
204+
}
205+
}
206+
207+
return { ...state, points, ...calculatePath( points ) };
181208
}
182209

183210
}

0 commit comments

Comments
 (0)