GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing id.javascript.info — "Smart" tooltip kembali ke pelajaran "Smart" tooltippentingnya: 5 Write a function that shows a tooltip over an element only if the visitor moves the mouse to it, but not through it. In other words, if the visitor moves the mouse to the element and stops there – show the tooltip. And if they just moved the mouse through, then no need, who wants extra blinking? Technically, we can measure the mouse speed over the element, and if it’s slow then we assume that it comes “over the element” and show the tooltip, if it’s fast – then we ignore it. Make a universal object Its
An example of using such object for the tooltip:
The demo: If you move the mouse over the “clock” fast then nothing happens, and if you do it slow or stop on them, then there will be a tooltip. Please note: the tooltip doesn’t “blink” when the cursor moves between the clock subelements. The algorithm looks simple:
But how to measure the speed? The first idea can be: run a function every Unfortunately, there’s no way to get “current mouse coordinates” in JavaScript. There’s no function like The only way to get coordinates is to listen for mouse events, like So let’s set a handler on P.S. Please note: the solution tests use |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |