←back to thread

Show HN: Boing

(boing.greg.technology)
269 points gregsadetsky | 4 comments | | HN request time: 0.001s | source
1. junon ◴[] No.46093925[source]
Love this. Had to cheat, naturally.

    setInterval(()=>{const canvas=document.getElementById('canvas');const startX=266;const startY=198;const rect=canvas.getBoundingClientRect();const startClientX=rect.left+startX;const startClientY=rect.top+startY;let endClientX,endClientY,distance;do{endClientX=Math.random()*window.innerWidth;endClientY=Math.random()*window.innerHeight;const dx=endClientX-startClientX;const dy=endClientY-startClientY;distance=Math.sqrt(dx*dx+dy*dy)}while(distance<25);const dispatchMouseEvent=(type,target,clientX,clientY)=>{const event=new MouseEvent(type,{view:window,bubbles:true,cancelable:true,clientX:clientX,clientY:clientY,screenX:clientX+window.screenX,screenY:clientY+window.screenY,buttons:type==='mouseup'?0:1,button:0});target.dispatchEvent(event)};dispatchMouseEvent('mousedown',canvas,startClientX,startClientY);setTimeout(()=>{dispatchMouseEvent('mousemove',window,endClientX,endClientY);setTimeout(()=>{dispatchMouseEvent('mouseup',window,endClientX,endClientY)},1);},1);},1);
replies(3): >>46094346 #>>46094456 #>>46094585 #
2. jesse__ ◴[] No.46094346[source]
take my upvote. That's hilarious
3. ngkw ◴[] No.46094456[source]
I love this.
4. meesles ◴[] No.46094585[source]
BoingBoingBoingBoingBoing