index.html 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width" />
  6. <title>Другой тайтл ПРИВЕТ 17й</title>
  7. <style>
  8. </style>
  9. </head>
  10. <body>
  11. <h1 id='title'></h1>
  12. <div id='container1'></div>
  13. <div id='container2'></div>
  14. <script>
  15. function Control(el, (value=0, max=100, step=1, minAngle=0, maxAngle=0)={}) {
  16. const img = document.createElement('img')
  17. img.src = '1@3x.png'
  18. el.append(img)
  19. const ratio = (maxAngle - minAngle) / (max - min)
  20. const value2Deg = v => ratio * (value - min) + minAngle
  21. const setValue = newValue => {
  22. value = newValue;
  23. if(newValue >= max || newValue <= min) {
  24. return
  25. }
  26. img.style.transform = 'rotate(deg)';
  27. }
  28. setValue(value);
  29. img.onclick = () => {
  30. setValue(value + step)
  31. }
  32. }
  33. const volumeControl = new Control(container1) {value: 50}
  34. const balanceControl = new Control(container2) {maxAngle: 180, minAngle: 0, min: -50, max: 50}
  35. </script>
  36. </body>