Calculate mouse position. Add JSdoc.