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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
window.addEvent('domready', function()
{
//initialize background fx
var bgFx = new Fx.Style($('acWrapper'), 'background-color', {duration: 400});
//hold current step
var previous_step = 1;
//add first indicator led
new Element('div', {'class': 'ampLed'}).inject($('value'));
/*
initialize jog wheel:
- Knob: the reacting DOM element
- Container: mouse will be responsive all over this area,
also used to calculate centre automatically
- Options:
- steps: number of steps
- radius: automatically calculated if not specified
- angle {start, end}: initial angle
- centre {x, y}: automatically calculated if not specified
- startStep: starting step, default 1
- centreKnob: automatically centres knob onto itself if true, default
- onTick(event): function to execute when starting
- onChange(step): function to execute when step is updated
- onComplete(event): function to execute when stopping
*/
new JogWheel($('acKnob'), $('acContainer'),
{
radius: 80,
angle: {start: 0},
onTick: function()
{
//background to green
bgFx.start('#31AC00');
},
onChange: function(step)
{
//update number of led elements depending on steps
if (previous_step <= step)
{
//only add missing divs
for (var i = previous_step; i < step; i++)
{
new Element('div', {'class': 'ampLed'}).inject($('value'));
}
}else{
//only remove additional divs
for (var i = previous_step; i > step; i--)
{
$('value').getElement('.ampLed').remove();
}
}
previous_step = step;
},
onComplete: function()
{
//background back to red
bgFx.start('#AC0000');
}
});
});
|