This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mdGestures): greatly improve emulated click hijacking
This commit greatly extends the click-hijacking functionality of `$mdGestures`. **Background:** iOS emulates click events on a `350ms` delay in order to avoid sending clicks when users pan, perform gestures, etc. This leads to pages often feeling laggy in mobile browsers. This appears to be less of an issue in Safari, but is a major issue in embedded webview applications such as Chrome on iOS and PhoneGap built apps. To get around this `$mdGesture` previously `touchstart` and `touchend` events and manually dispatches `click` events. This allows them to happen much quicker than the 350ms. It then configures the page to ignore clicks that were not originated by `$mdGesture`. **Problem:** While `$mdGesture` did successfully hijack the `click` event, it did not hijack other emulated events from iOS, including `mouseup`, `mousedown` and the subsequent `focus` event that could originate from a delayed `click`. **Example of problem:**: Issue #4850 was caused by the `md-select` opening quickly via our simulated `click` event, followed by receiving a `350ms` OS delayed `mousedown` event resulting in an option immediately being selected. Some other example problems that impact the framework: - Ink ripples are 350ms delayed (use `mousedown` and `mouseup`) - Some components / items randomly ripple or trigger after being focused / click. Usually this isn't an issue, but can be (eg. #4850) - `focus` events are 350ms delayed (Affects input) **Soltuion:**: This PR makes `$mdGesture` perform hijacking of `mousedown`, `mouseup` and subsequent `focus` events in order to more quickly dispatch them. **Notes:** A few of our internal components needed some refactoring as they were properly discarding the emulated `mousedown` (which is now ignored DOM wide) and relying on those events for state, etc. Ripples will need a fix as they now properly ripple on `mousedown` but can hit a situation where they receive no later `mouseup` event. Perhaps listening to the document-wide `mouseup` event should be registered on `mousedown`. An example is scrolling in the Docs' Sidenav via touch. closes #4850, closes #4757
- Loading branch information
1 parent
2ff4f9b
commit 446df80
Showing
4 changed files
with
83 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Used only to optionally test | ||
// jQuery w/ docs (see docs/gulpfile#docs-js) |
This file contains 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 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 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