numKeysJumpTo.js 571 B

1234567891011121314151617181920212223
  1. (() => {
  2. const timeSteps = 9; // excluding 0
  3. function getX(timeKey, maxWidth) {
  4. if(timeKey >= timeSteps)
  5. return maxWidth;
  6. return Math.floor(maxWidth / timeSteps) * timeKey;
  7. }
  8. const elem = document.querySelector("#sliderBar");
  9. const rect = elem.getBoundingClientRect();
  10. const x = getX(1, rect.width);
  11. const y = (rect.top + rect.bottom) / 2;
  12. const evt = new MouseEvent("mousedown", {
  13. clientX: x,
  14. clientY: y,
  15. target: elem,
  16. bubbles: true,
  17. view: window,
  18. });
  19. document.body.dispatchEvent(evt);
  20. })();