[Fix issue #1152] Enhance event-flick module with flickleft, flickright, flickup, flickdown sugar events #1323
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.
This pull request fixes issue #1152 by enhancing the
event-flick
module.What's in this pull request?
flick*
eventsAdded 4 new synthetic "sugar" events that developers can hook on to:
flickleft
flickright
flickup
flickdown
These events have the exact same public API as the generic
flick
event, but fire only when theaxis
anddirection
properties match up to the respective directions.Bit of code cleanup
I separated out the monolithic
_onEnd()
callback into smaller functions:_onEnd()
_isValidFlick()
_fireEvent()
This helped me re-use a large portion of the CustomEvent config object when defining the new
flick*
events. These new events only overwrite the_isValidFlick()
method. Check outIn addition to that, there was some minor code cleanup to make the code more readable.
minDistance
default value changeI made a change in the
flick
event'sminDistance
property. By default, its value is now100
, so that it catches a legitimate flick, instead of a slight move of the finger. I believe it was10
before.Improve Test Coverage
event-flick
did not have great tests. There were only 3 of them and they probably weren't working correctly because the assertions were inside a customfire()
method. Iffire()
wasn't called, the tests would pass anyway, since an empty test with no assertions passes. I improved the way the tests are written and added a bunch of new tests.event-flick
has ~98% line coverage in all browsers. I'm not usingevent-simulate
so these tests are very stable.I also added a new manual test (
flick-simple.html
).Tested on:
If someone has an Android device running on a newer Android version, it would be great if you can help me test this. No need to pull it down, just ping me and I can give you a URL that you can hit on your browser to run through the unit and manual tests.
TODO before merging
This is so I don't forget.
event-flick
documentation