It was very hard to keep tooltip within screen & its' arrow. getBoundingClientRect() method of global object can help you to calculate your element's position.
What specific areas of your project would you like help with?Optimizing & refactor my code, that's the only wish.