-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (33 loc) · 1.12 KB
/
index.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
const selectedColorBox = document.querySelector('.selected-color-box');
const sizeInputs = document.querySelectorAll('.input-box .input input');
var sliderColor = '#000';
const rgbSlider = require('./modules/rgb-slider');
const paintingGrid = require('./modules/painting-grid');
const {
updatePaintingGridSize,
updatePaintingGridColor,
downloadPainting
} = paintingGrid(document);
const { sliderRange, fixSlider } = rgbSlider(document);
handleSliderChange();
sliderRange.oninput = function() {
handleSliderChange();
}
function handleSliderChange() {
sliderColor = fixSlider();
selectedColorBox.style.backgroundColor = sliderColor;
selectedColorBox.innerHTML = sliderColor;
updatePaintingGridColor(sliderColor);
}
updatePaintingGridSize(sizeInputs[0].value);
sizeInputs[0].oninput = function(e) {
sizeInputs[1].value = e.target.value;
updatePaintingGridSize(sizeInputs[0].value);
}
sizeInputs[1].oninput = function(e) {
sizeInputs[0].value = e.target.value;
updatePaintingGridSize(sizeInputs[0].value);
}
document.querySelector('.button-download').addEventListener('click', function() {
downloadPainting();
}, false);