How to Determine the Middle of Cursor?
One of the most interesting aspects was that the tooltip appears in the middle of our cursor. How can we do that? Let's find out in this lesson.
We'll cover the following...
What we have so far #
So far, we’ve investigated if we can use constant character widths to determine the middle, and we’ve tried to use the getSelection
method alone to provide all the information we need.
We know that we’ll certainly have to use some information from getSelection
, since it reliably gives us the selected characters. So the problem becomes this: given a string of characters in an HTML node, find the x and y offsets of the middle (so that we can have ...