Added check for visibility of canvas when clicked