getBoundingClientRect is not a function

That means that canvas variable is not actually a Canvas element.

It can be undefined, still not initialized or incorrectly selected.

You need to double check it and maybe try to use event.target if the click event is added to the canvas element.

Leave a Comment