-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCutNPropertyComponent.js
41 lines (33 loc) · 1.41 KB
/
CutNPropertyComponent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class CutNPropertyComponent{
textboxOnChange(cutRange, multiplier, dimension){
return function(e){
let newValue = parseFloat(e.srcElement.value);
cutRange.value = newValue * multiplier;
emit('signalCutLocationChange', dimension, newValue);
}
}
rangeOnChange(cutTextbox, multiplier, dimension){
return function(e){
let newValue = parseFloat(e.srcElement.value);
cutTextbox.value = Math.round(newValue / multiplier * 100) / 100;
emit('signalCutLocationChange', dimension, newValue / multiplier);
}
}
constructor(N, relativeN, startingValue, maxValue, parent){
this.N = N;
this.relativeN = relativeN;
const sliderMultiplier = 100;
console.log('cut', N, startingValue, maxValue)
var mainDiv = document.createElement('div');
mainDiv.appendChild(document.createTextNode('Dimension ' + N + ' Cut'));
br(mainDiv)
let locationDiv = document.createElement('div');
mainDiv.appendChild(locationDiv)
var cutTextbox = labeledTextbox(locationDiv, 'cut'+N+'Textbox', 'Location:', startingValue, 10, false, false)
br(mainDiv)
var cutRange = range(mainDiv, 'cut'+N+"Range", -maxValue* sliderMultiplier, maxValue*sliderMultiplier, startingValue)
cutTextbox.onchange = this.textboxOnChange(cutRange, sliderMultiplier, this.relativeN)
onRangeChange(cutRange, this.rangeOnChange(cutTextbox, sliderMultiplier, this.relativeN))
parent.appendChild(mainDiv)
}
}