Tooltip mousetracking problem

They have: 37 posts

Joined: Jun 2006

Hi!
Can anyone help me with this? I've found the best looking JavaScript tooltip ever, but it had two major flaws. It applied to all the links on a page, which I sorted out and now it works only within a defined DIV. The other problem is something I can't fix. The tooltip doesn't follow the mouse movement properly and so far all my attempts to fix it failed. Can someone try to fix it?
Here you can download the code: http://www.dustindiaz.com/downloads/sweet-titles.zip

One more thing...If you are going to send me a link to JS resources, don't bother. I've tried all of them.

Raise And Share a Million.com - Rewarding to those who like to help others

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Can you explain in more detail?

As I understand it, you want for the tooltip box, when visible, to move as you move the mouse. That's not generally how tooltips work so I'm not sure it's a good idea. Once visible, a tooltip stays put until it becomes invisible again.

Or do you mean it doesn't show up in the right place at all?

Smiling

They have: 37 posts

Joined: Jun 2006

Abhishek Reddy;209741 wrote:

As I understand it, you want for the tooltip box, when visible, to move as you move the mouse.

Smiling

That's exactly what I mean. There will be more images close to each other and I need the tooltip to copy the mouse movement. Otherwise the user might get the idea they need to click the link inside the tooltip and start chasing it. If it moves along with the pointer it will be obvious the tooltip is just a description of the image.
Can you fix it?

Raise And Share a Million.com - Rewarding to those who like to help others

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

It can be done. But there are a couple of points to keep in mind:

- For one, as I said, it's not conventional to have a tracking tooltip, so it will somewhat defeat the purpose of the script, imo.

- It takes a lot more work by the script track the pointer, since it has to trigger an event for every unit of movement -- usually non-uniform. When many events queue up or conflict, the tooltip might flicker, appear offset, move around, or fail to disappear.

That said, attached to this post is a modified version of sweetTitles.js from the package you linked, with support for tracking tooltips.

Works pretty smoothly in Konqueror 3.5 and Firefox 2.0. While I took some measures to avoid weird behaviour, it's only a quick hack. I haven't tested it much, so keep in mind my second point above as a disclaimer. Wink

I guess you'll have to apply your own adjustments again. Hope they don't conflict. Smiling

AttachmentSize
sweetTitles.js 13.87 KB

They have: 37 posts

Joined: Jun 2006

PERFECT!!!! You're THE MAN!
Thank you.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

You may not still be interested, but... Wink

There are a couple of minor issues with the previous script I posted, so I modified it again for the version attached in this post.

- With mouse tracking, the tooltip jumps around a bit if you move it near the edges of your browser window, which isn't very nice. Now it keeps still in two of three edge cases, and hops around only when it makes sense to.

- Diaz's original uses innerHTML to populate the tooltip -- that's not in the DOM-2 spec and should be avoided if possible. I rewrote that bit with only DOM-2 interfaces and methods.

However, again, I haven't tested it much (especially not in IE). Still works in Konqueror 3.5 and Firefox 2.0.

And if the tooltip's appearance is any different, you'll only need to tweak your CSS to suit. I've attached a new default CSS file that styles it to look the same as the original default.

Smiling

AttachmentSize
sweetTitles.css 16.56 KB

They have: 37 posts

Joined: Jun 2006

I am lost for words, mate. I didn’t expect anyone to play with it that much. I believe if you posted your modifications to dustindiaz.com/sweet-titles-finalized/ you’ll find many more thankful people. And guess what….your mod is working fine in IE as well. I am launching my new web site on 20. November, so I’ll send you the link. You might be interested in taking part in it. It is a global charity project and if you suggest a charity from New Zealand, they’ll benefit from it.
Once again, THANK YOU.

Raise And Share a Million.com - Rewarding to those who like to help others

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.