Improve event-move to have dual-listener support, better unit tests, better logic for handing options #1309

wants to merge 7 commits into from

2 participants


This pull request improves the event-move module, and is the first step towards having better gesture events in YUI, as discussed in this YUI-Contrib post.


As I mentioned in the YUIContrib post, it's important for YUI to have abstracted low-level start/move/end events. Originally, I was going to write these from scratch, but upon thinking about it more, this idea was already encapsulated within the event-move module. Unfortunately, it hadn't received some love in a while, so that's what I did here. No point creating new modules which duplicated the logic that was present in event-move. I just took what was in here and made it better.

Yes, there is the problem of someone not being able to subscribe to gesturemove if they don't subscribe to gesturemovestart as well, but this isn't really a problem because they can just set standAlone: true. In fact, maybe standAlone should be true by default. Not sure what you guys think about that. I didn't change that in this PR because it's a little outside the scope of it.

What's in this pull request?

  • event-move now has dual-listener support so that it works great in devices that support both mouse and touch
  • There was a long-standing bug in event-move regarding the minTime and minDistance options that could be passed into it. Since these options can be configured, there are actually 4 possible scenarios:
    • minTime = 0, minDistance = 0
    • minTime > 0, minDistance = 0
    • minTime = 0, minDistance > 0
    • minTime > 0, minDistance > 0 The old code did not have 4 separate paths for some reason. I branched the code to support all 4 use-cases.
  • Improved unit test coverage so that it's 90%+, and improved how the tests are written.
  • Created a more useful manual test page (gestures.html)

Test Coverage

This module has 90%+ test coverage. Some of the code is skipped on non-MSPointer environments, so test in IE10 for maximum coverage. Looking at the skipped lines though, they aren't areas which should give bugs. I can improve the coverage more if needed, but wanted to get the code out so it could be reviewed.

I tested this code on:

  • IE7+
  • Latest Chrome
  • Latest FF
  • Latest Safari
  • Android 4.0.3
  • iOS7

Going Forward

Going forward, I want to improve the event-flick and add a few more gesture events to the library. We can use event-move as the de-facto low-level abstracted input event layer for YUI.

Todos Before Merging

This is just so that I don't forget.

  • Update docs for event-move
  • Commit build files

Has anyone had a chance to look at this?


Would your Hammer.js work render this out of date @tilomitra ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment