Why isn't javascript registering this onmouseup event?

53 Views Asked by At

I am trying to create a "drawing" thing in javascript with dots, and it doesn't seem to be registering the onmouseup event. What is wrong with this code?

let interval = null;
const mouseDown = 0;
document.body.onmousedown = function () {
  D = document, B = D.body, a = [], p = [], D.onmousemove = function (e) {
    (d = p[0] ? p.pop() : D.createElement('p')).setAttribute('style', `${t = 'border-radius:5px;'}-moz-${t}-webkit-${t}position:absolute;left:${e.clientX}px;top:${e.clientY}px;padding:5px;background:#${(`00${((4095 * Math.random())).toString(16)}`).substr(-3)}`), a.push(B.appendChild(d));
  }, interval = setInterval(() => {
    if (a[0]) for (; p.push(B.removeChild(a.shift())), a[1e4];);
  }, 1e3);
}, document.body.onmouseup = function () {
  clearInterval(interval);
};

0

There are 0 best solutions below