-
Notifications
You must be signed in to change notification settings - Fork 57
Moving the mouse: mouseover/out, mouseenter/leave #232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
pierangelomiceli
wants to merge
39
commits into
javascript-tutorial:master
from
pierangelomiceli:016_movingmouse
Closed
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
ce0f88c
traduzione articolo, task e solution
pierangelomiceli fa4d924
traduzione articolo
pierangelomiceli b7106d6
traduzione task and solutions
pierangelomiceli 2e2be58
fine traduzioni task e solutions
pierangelomiceli b1e0401
modifica task e solution
pierangelomiceli 771e139
prime modifiche
pierangelomiceli 0b8b60f
altremodifiche
pierangelomiceli 6df0d3b
eliminazione modifiche avulse
pierangelomiceli a1f1b1a
fine modifiche articolo
pierangelomiceli 022b0da
altre traduzioni
pierangelomiceli 2a7552b
modifiche alla traduzione dell'articolo
pierangelomiceli cb283b6
modifica task sol1
pierangelomiceli 08b80d5
correzioni task sol 2
pierangelomiceli 365dab5
cambio titolo
pierangelomiceli d65aec0
traduzioni residue
pierangelomiceli 28d5657
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pierangelomiceli 7ee3383
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pierangelomiceli 3b43de9
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pierangelomiceli 98ffe81
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pierangelomiceli 3894b47
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pierangelomiceli 3a268d1
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pierangelomiceli d1efa83
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pierangelomiceli 5831974
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pierangelomiceli c48bc3e
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pierangelomiceli 35f5df3
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pasor1 67e790d
Update hoverIntent.js
pasor1 cdb9182
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pasor1 e1e0ce1
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pasor1 3407a60
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pasor1 4eea7d4
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pasor1 ba8ee30
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pasor1 5daca2d
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pasor1 276d01a
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pasor1 bb18984
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pasor1 c73d129
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pasor1 a2848e8
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pasor1 088e747
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pasor1 a092649
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pasor1 0ce6c7c
Update 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter…
pasor1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 11 additions & 11 deletions
22
.../3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
|
||
The algorithm looks simple: | ||
1. Put `onmouseover/out` handlers on the element. Also can use `onmouseenter/leave` here, but they are less universal, won't work if we introduce delegation. | ||
2. When a mouse cursor entered the element, start measuring the speed on `mousemove`. | ||
3. If the speed is slow, then run `over`. | ||
4. When we're going out of the element, and `over` was executed, run `out`. | ||
L'algoritmo è semplice: | ||
1. Impostare dei gestori `onmouseover/out` sull'elemento. Qui si possono anche usare `onmouseenter/leave`, però sono meno universali, e non funzionerebbero se introducessimo l'uso della delegation. | ||
2. Quando il puntatore è entrato dentro l'elemento, si comincia a misurare la velocità al `mousemove`. | ||
3. Se la velocità è lenta, eseguire `over`. | ||
4. Quando si esce fuori dall'elemento, ed è stato eseguito `over`, eseguire `out`. | ||
|
||
But how to measure the speed? | ||
Ma come misurare la velocità? | ||
|
||
The first idea can be: run a function every `100ms` and measure the distance between previous and new coordinates. If it's small, then the speed is small. | ||
La prima strategia potrebbe essere: eseguire una funzione ogni `100ms` e misurare la distanza tra le vecchie e nuove coordinate. Se fosse piccola, anche la velocità lo sarebbe. | ||
|
||
Unfortunately, there's no way to get "current mouse coordinates" in JavaScript. There's no function like `getCurrentMouseCoordinates()`. | ||
Sfortunatamente, non c'è modo di ricavare "le coordinate attuali del mouse" in JavaScript. Non esistono funzioni come `getCurrentMouseCoordinates()`. | ||
|
||
The only way to get coordinates is to listen for mouse events, like `mousemove`, and take coordinates from the event object. | ||
L'unico modo è di mettersi in ascolto sugli eventi del mouse, come `mousemove`, e prendere le coordinate dall'oggetto evento. | ||
|
||
So let's set a handler on `mousemove` to track coordinates and remember them. And then compare them, once per `100ms`. | ||
Quindi impostiamo un gestore su `mousemove` per tenere traccia delle coordinate e memorizzarle, per poi confrontarle ogni `100ms`. | ||
|
||
P.S. Please note: the solution tests use `dispatchEvent` to see if the tooltip works right. | ||
P.S.: Nota bene: i test della soluzione fanno uso di `dispatchEvent` per vedere se il tooltip funziona bene. | ||
pierangelomiceli marked this conversation as resolved.
Show resolved
Hide resolved
pierangelomiceli marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.