- Notifications
You must be signed in to change notification settings - Fork179
Moving the mouse#620
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Moving the mouse#620
Changes fromall commits
Commits
Show all changes
9 commits Select commitHold shift + click to select a range
b85cab0
2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mousel…
dolgachioc493c5c
2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mousel…
dolgachiof02c212
2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mousel…
dolgachio7653c34
2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mousel…
dolgachio8626b82
2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mousel…
dolgachiod7052eb
Merge branch 'javascript-tutorial:master' into master
dolgachio3581cab
Apply suggestions from code review
dolgachioc7fe06b
Apply suggestions from code review
dolgachio6b02e54
Apply suggestions from code review
dolgachioFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
34 changes: 17 additions & 17 deletions...useover-mouseout-mouseenter-mouseleave/1-behavior-nested-tooltip/solution.view/index.html
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
16 changes: 8 additions & 8 deletions...mouseover-mouseout-mouseenter-mouseleave/1-behavior-nested-tooltip/source.view/index.html
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
18 changes: 9 additions & 9 deletions...move-mouseover-mouseout-mouseenter-mouseleave/1-behavior-nested-tooltip/task.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
22 changes: 11 additions & 11 deletions.../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 @@ | ||
Алгоритм виглядає просто: | ||
1.Додайте обробники`onmouseover/out`на елемент. Тут також можна використовувати`onmouseenter/leave`, але вони менш універсальні, і не працюватимуть, якщо ми використаємо делегування подій. | ||
2.Коли вказівник миші увійшов на елемент, почніть вимірювати швидкість на `mousemove`. | ||
3.Якщо швидкість низька, то запускаємо `over`. | ||
4.Коли вказівник виходить за межі елемента, і `over`закінчила свою роботу, запускаємо `out`. | ||
Але як виміряти швидкість? | ||
Перша ідея може бути такою: запускати функцію кожні`100ms`і вимірювати відстань між попередньою та новою координатами. Якщо відстань маленька, то швидкість невелика. | ||
На жаль, у JavaScript немає способу отримати поточні координати вказівника миші. Немає таких функцій, як `getCurrentMouseCoordinates()`. | ||
Єдиний спосіб отримати координати -- в обробнику подій миші, наприклад `mousemove`,і брати координати з об’єкта події. | ||
Отже, давайте додамо обробник на`mousemove`, де відстежемо і запам'ятаємо поточні координати. А далі будемо порівнювати їх раз на `100ms`. | ||
P.S.Зверніть увагу: тести рішення використовують`dispatchEvent`, щоб перевірити, чи підказка працює правильно. |
26 changes: 13 additions & 13 deletions...emove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/solution.view/hoverIntent.js
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
18 changes: 9 additions & 9 deletions...usemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/source.view/hoverIntent.js
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.
Uh oh!
There was an error while loading.Please reload this page.
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.