-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (29 loc) · 850 Bytes
/
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
const radio = document.querySelectorAll('input[type=radio][name=svg]');
radio.forEach(selected => {
selected.addEventListener('change', v => {
const newValue = v.target.value;
changePattern(newValue);
});
});
let selectedSVG;
function changePattern(svgName) {
selectedSVG = fetch(`./svgs/${svgName}.svg`)
.then(r => r.text())
.then(text => {
const container = document.createElement('div');
container.innerHTML = text;
return container.children[0];
})
// .then(svg => flatten(svg))
.then(svg => {
console.log('Changing svg');
return {
svg: svg,
width: svg.getAttribute('width'),
height: svg.getAttribute('height')
}
});
selectedSVG.then(()=>{warpIfNotAlready()})
}
changePattern('square');
const scaleElement = document.getElementById('scale');