fr.javascript.info
fr.javascript.info copied to clipboard
interrupting the ball displacement when the cursor go off zone
This will fix the bug that keeps the ball to follow the cursor when going off the container zone. At this moment you need to reload the page to get rid of this bug.
Just add this :
document.addEventListener('mouseout', function() {
ball.dispatchEvent(new Event('mouseup'));
});
You may need to adapt document to the container that you use in your example.