]>
git.r.bdr.sh - rbdr/lissajous/blob - lib/factories/ui.js
cc34579f55ba06d6089c9129d2d1df7a89eac8c0
1 export function settingsContainer({id
, label
, level
=2}) {
3 const container
= document
.createElement('section');
5 container
.innerHTML
= `<h${level}>${label}</h${level}>`;
9 export function slider({
21 const sliderContainer
= document
.createElement('section');
22 sliderContainer
.classList
.add('slider');
23 sliderContainer
.classList
.add(className
);
24 const labelElement
= document
.createElement('label');
25 labelElement
.setAttribute('for', id
);
26 labelElement
.innerHTML
= label
;
27 const slider
= document
.createElement('input');
29 slider
.type
= 'range';
33 slider
.value
= get().toString();
36 document
.addEventListener('keydown', function(event
) {
38 slider
.classList
.add('shifted');
39 slider
.step
= shiftStep
;
43 document
.addEventListener('keyup', function(event
) {
44 if (event
.key
=== 'Shift') {
45 slider
.classList
.remove('shifted');
50 document
.addEventListener('touchstart', function(event
) {
51 if (event
.touches
.length
== 3) {
52 if (slider
.classList
.contains('shifted')) {
53 slider
.classList
.remove('shifted');
56 slider
.classList
.add('shifted');
57 slider
.step
= shiftStep
;
63 slider
.addEventListener('input', () => set(slider
.value
));
65 sliderContainer
.appendChild(labelElement
);
66 sliderContainer
.appendChild(slider
);
67 return sliderContainer
;