Bug fix in calculation, and event dispatch for click event.