Skip to content
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

Fix #5 and add tests for touch functionality #6

Merged
merged 2 commits into from
Apr 21, 2015
Merged

Conversation

motiz88
Copy link

@motiz88 motiz88 commented Mar 10, 2015

In this PR, I have:

  • Removed the globals root and bodyElement in favor of always setting and clearing events on this.getDOMNode().ownerDocument.body.
  • Removed isTouchDevice and the either/or relationship between touch and mouse events in favor of tracking the source device on a per-drag basis. This tracking relies on having separate handlers for touch and mouse events; For the record, my earlier approach of just inspecting event.type in the shared handlers did not pan out, because TestUtils.Simulate doesn't seem to set that property.
  • Removed dragEventFor in favor of dragEventsFor.mouse and dragEventsFor.touch.
  • Changed the semantics of state.dragging slightly - its value is now always one of false, 'touch' and 'mouse'. This is mainly so that a stray mouseup doesn't interfere with an ongoing touch-based drag operation, and vice versa.
  • Added tests that use simulated touch events alongside the existing ones for mouse events. (All tests pass on my machine, but please see Missing an automated test for onDrag #7)

},

handleDragStart: function (e) {
handleMouseUp: function(e) {
return this.handleDragEnd(e, 'mouse');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add e.preventDefault() here too?
http://www.html5rocks.com/en/mobile/touchandmouse/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, absolutely, just ran into that myself. (Though in that case the preventDefault line should probably just move to handleDrag)

- onMouseDown, onMouseUp, onTouchStart, onTouchEnd props now supported.
- The above user event handlers can now call preventDefault() and cleanly override drag actions.
- Added tests of above functionality.
- In the internal handlers, preventDefault() is called if and only if a drag operation is started. This prevents scrolling / text selection.
- Modified the example to only hide user selection on the <strong/> drag handles.
mikepb added a commit that referenced this pull request Apr 21, 2015
Fix #5 and add tests for touch functionality
@mikepb mikepb merged commit af08f76 into mikepb:master Apr 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants