Skip to content

Commit 37257de

Browse files
committed
curve: add scaleable background
1 parent 997f174 commit 37257de

File tree

7 files changed

+62
-21
lines changed

7 files changed

+62
-21
lines changed

app/build/mojs-curve-editor.js

Lines changed: 23 additions & 10 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.postcss.css

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

app/css/blocks/curve.postcss.css.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"curve":"_curve_19x0u_5","curve__svg-wrapper":"_curve__svg-wrapper_19x0u_1","curve__svg":"_curve__svg_19x0u_1","curve__svg-segment":"_curve__svg-segment_19x0u_1"}
1+
{"curve":"_curve_3s9gm_5","curve__background":"_curve__background_3s9gm_1","curve__svg-wrapper":"_curve__svg-wrapper_3s9gm_1","curve__svg":"_curve__svg_3s9gm_1","curve__svg-segment":"_curve__svg-segment_3s9gm_1"}

app/js/tags/curve.tag

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11

22
require('./point');
33

4-
<curve class={ this.CLASSES['curve']} style={this.styles.background}>
4+
<curve class={ this.CLASSES['curve']}>
5+
6+
<div
7+
class={ this.CLASSES['curve__background']}
8+
style={this.styles.background} />
9+
510
<div class={ this.CLASSES['curve__svg-wrapper']} style={this.styles.transform}>
611

712
<point
@@ -123,13 +128,19 @@ require('./point');
123128
this.getStyle = () => {
124129
const {resize} = this.state;
125130
let {temp_top} = resize;
131+
let {temp_bottom} = resize;
132+
let {temp_right} = resize;
126133

127134
temp_top += resize.top;
135+
temp_bottom += resize.bottom;
136+
temp_right += resize.right;
128137

129138
if (C.CURVE_SIZE - temp_top < C.CURVE_SIZE) { temp_top = 0; }
130139
temp_top = mod( temp_top, -1 );
131140

132-
const background = `background-position: 0 ${-temp_top - 1}px`;
141+
const scale = `transform: scaleX(${(C.CURVE_SIZE + Math.max(temp_right,0))/C.CURVE_SIZE})`;
142+
const bgTransform = `${mojs.h.prefix.css}${scale}; ${scale};`;
143+
const background = `background-position: 0 ${-temp_top - 1}px; height: ${C.CURVE_SIZE + Math.max(Math.abs(temp_top), 0) + Math.max(temp_bottom, 0)}px; ${bgTransform}`;
133144
const transform = `transform: translate(0px, ${-temp_top}px)`;
134145

135146
return {

app/js/tags/point.tag

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ require('./little-handle');
8989
returnValue = e.deltaY;
9090
}
9191

92-
return roundTo( returnValue, 5*C.CURVE_PERCENT, 1*C.CURVE_PERCENT );
92+
return roundTo( returnValue, 5*C.CURVE_PERCENT, 2*C.CURVE_PERCENT );
9393
}
9494

9595
this.on('mount', () => {
@@ -99,10 +99,12 @@ require('./little-handle');
9999
mc.add(new Hammer.Pan({ threshold: 0 }));
100100
mc
101101
.on('pan', (e) => {
102+
console.time('point translate');
102103
store.dispatch({
103104
type: 'POINT_TRANSLATE',
104105
data: { x: getTempX(e), y: getTempY(e), index: this._index }
105106
});
107+
console.timeEnd('point translate');
106108
e.stopPropagation();
107109
})
108110
.on('panend', (e) => {

app/js/tags/resize-handle.tag

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
require('../../css/blocks/icon');
1717

1818
this.on('mount', () => {
19-
var hammertime = propagating(new Hammer(this.root))
19+
const mc = propagating(new Hammer.Manager(this.root));
20+
mc.add(new Hammer.Pan({ threshold: 0 }));
21+
mc
22+
// var hammertime = propagating(new Hammer(this.root))
2023
.on('pan', (ev) => {
2124
const x = ev.deltaX, y = ev.deltaY;
2225
store.dispatch({ type: 'EDITOR_RESIZE', data: { x, y, type } });

0 commit comments

Comments
 (0)