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

Adds touch events for mobile devices. #9

Closed
wants to merge 1 commit into from

Conversation

5minpause
Copy link

As discussed in #5 this is a draft for touchEvents.
I have no experience with JS tests and haven’t looked into it. Could I get a quick look at it, if this makes sense? I tried it out on iOS simulator and on an actual iPhone and it worked kind of. If the user drags vertically, the page starts to scroll. Then the dragging isn’t visibile until the scrolling stops (This happens because scrolling on iOS is done with a screenshot of the actual page).

So, any comments on this?

Shouldn’t be viewed as final as
scrollEvents make vertical dragging difficult.
@mzabriskie
Copy link
Collaborator

@5minpause should be able to fix problem with scrolling by adding another event when dragging starts, then clean it up once dragging ends.

// added to onMouseDown
addEvent('touchmove', preventDefault);

// added to onMouseUp
removeEvent('touchmove', preventDefault);

// added to draggable.js
function preventDefault(event) {
  event.preventDefault();
}

Also a few changes for your PR:

  • Use single quotes
  • Remove console.log
  • Don't define clientX/clientY twice in handleMouseMove
var clientX, clientY;

if (/*...*/) {
  clientX = /*...*/;
  clientY = /*...*/;
} else {
  clientX = /*...*/;
  clientY = /*...*/;
}

@5minpause
Copy link
Author

Thanks for the input. I have since developed it further including a maximumDragValue for x and y to make the dragging stop as well as an offset. I am using it as a draggable slider. I'll clean it up and show you. Perhaps it’s of value. I don’t know which direction you’d like this to develop into.

@mzabriskie
Copy link
Collaborator

@5minpause what was the iOS simulator that you used?

@felixbuenemann
Copy link

He probably meant the iOS Simulator that comes with Xcode on Mac OS X.

@mzabriskie
Copy link
Collaborator

I've ended up going with #18 as a touch implementation

@mzabriskie mzabriskie closed this Oct 21, 2014
@5minpause
Copy link
Author

Great, thanks. I didn’t get around doing it.

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.

None yet

3 participants