forked from GustavLindberg99/NuclideChart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstalinok.js
40 lines (33 loc) · 1.19 KB
/
stalinok.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
let zoomArr = [0.5,0.75,0.85,0.9,1,1.2,1.5];
var element = document.querySelector('.maindiv');
let value = element.getBoundingClientRect().width / element.offsetWidth;
let indexofArr = 4;
handleChange = ()=>{
let val = document.querySelector('#sel').value;
val = Number(val)
console.log('handle change selected value ',val);
indexofArr = zoomArr.indexOf(val);
console.log('Handle changes',indexofArr)
element.style['transform'] = `scale(${val})`
}
document.querySelector('.zoomin').addEventListener('click',()=>{
console.log('value of index zoomin is',indexofArr)
if(indexofArr < zoomArr.length-1){
indexofArr += 1;
value = zoomArr[indexofArr];
document.querySelector('#sel').value = value
// console.log('current value is',value)
// console.log('scale value is',value)
element.style['transform'] = `scale(${value})`
}
})
document.querySelector('.zoomout').addEventListener('click',()=>{
console.log('value of index zoom out is',indexofArr)
if(indexofArr >0){
indexofArr -= 1;
value = zoomArr[indexofArr];
document.querySelector('#sel').value = value
// console.log('scale value is',value)
element.style['transform'] = `scale(${value})`
}
})