top | item 37417949

(no title)

Hexagon56k | 2 years ago

It was just a quickie for fun, but maybe I should look into that

discuss

order

spdustin|2 years ago

Yeah, I’d maybe make a set of just the position IDs, and do a negated .has() of that set to check if the cursor was removed.

    ws.onmessage = function(event) {
      const positionIds = new Set(positions.map(pos => pos.id));

      Object.keys(cursors).forEach((id) => {
        if (!positionIds.has(id)) {
            document.body.removeChild(cursors[id]);
          delete cursors[id];
        }
      });
    };
Untested but that’s probably pretty close for phone typing

Hexagon56k|2 years ago

Implemented and working, should probably move this whole thing outside ws.onmessage too, could be run every fifth second or so.

Hexagon56k|2 years ago

Any code written on a phone is impressive ^^ Will try it out