-
Notifications
You must be signed in to change notification settings - Fork 14
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
touchmove event coordinates #96
Comments
Thanks for filing an issue. As you've noted, A couple of questions:
Thanks! |
While the hardware supports multiple touches, two fingers get interpreted as zooming. I couldn't figure out replacing .bind with the newer .addEventListener according to https://stackoverflow.com/a/54738343. If zooming can be disabled, |
Good to know, thanks. I wasn't quite sure what that line of code in jQuery was doing in the first place, so it's nice to know that it's not essential for
Ah, OK. Unfortunately, neither of my devices have a touchscreen. (I have a laptop with a touchpad, but that's not quite the same thing.) I don't suppose there's any other way to mock
Alright. Do you have a small example program that you're testing this out on, by chance? I ask since having a reasonably sized, standalone test program would make it far easier to debug the issues you're experiencing. (Of course, I'd have to figure out if I can even get |
This program uses my changed blank-canvas and just prints out events on stdout https://github.com/aavogt/blank-canvas-touch-example |
OK, I was finally able to figure out a way to reproduce this locally by using a phone + USB debugging. And indeed, if I run your example with + if (e.originalEvent.touches != undefined
+ && e.originalEvent.touches.length > 0
+ && e.originalEvent.touches[0].pageX != undefined
+ && e.originalEvent.touches[0].pageY != undefined) {
+ o.pageXY = [e.originalEvent.touches[0].pageX, e.originalEvent.touches[0].pageY];
+ }
+ if (e.originalEvent.changedTouches != undefined
+ && e.originalEvent.changedTouches.length > 0
+ && e.originalEvent.changedTouches[0].pageX != undefined
+ && e.originalEvent.changedTouches[0].pageY != undefined) {
+ o.pageXY = [e.originalEvent.changedTouches[0].pageX, e.originalEvent.changedTouches[0].pageY];
+ } This is enough to get all Let me know if the code above works for your use case. If so, we can explore how to refine it (and eventually upstream it into |
fixes ku-fpg#96 Unfortunately this breaks every use of ePageXY
Your code works. But I only need the changedTouches part: if somebody else needed Here I support multiple touches aavogt@d3f7fe4 . We could break existing code in the following way: that module's splitEventS :: EventS -> [Event]
splitEventS (EventS metakey pagexy ...) = getZipList $
Event <$> pure metakey <*> ZipList (map Just pagexy) <*> ... It would also be nice to access the other properties of Touch such as force radiusX radiusY and rotationAngle. Should I prepare a pull request with the following Event or something like the Event in here, or something else? data Event = Event { eMetaKey :: Bool
ePageXY :: Maybe (Double, Double),
eTouchID :: Maybe Int,
eRadiusXY :: Maybe (Double, Double),
eRotationAngle :: Maybe Double,
eForce :: Maybe Double,
eType :: EventName,
eWhich :: Maybe Int
} |
Great, I'm glad to hear that that works for you. I'd welcome a pull request to add this functionality, keeping in mind the caveats below. One concern I have with adding support for touch-based events wholesale is that they don't appear to be portable across all browsers. In particular, this table suggests that they don't work on Safari, which is a pretty widely used browser. I don't think this is a dealbreaker, but I do think we should be careful to guard any JavaScript code that manipulates touches such that it doesn't break browsers that don't support them. We should also be sure to document this limitation in the Haddocks. As far as what the API should look like, I'm wondering if we should put all of the touch-specific properties into their own data type. Something like this, perhaps: data Touch = Touch
{ touchPageXYs :: [(Double, Double)]
, touchIDs :: [Int]
, touchForce :: Double
, ...
}
data Event = Event
{ eTouch :: Maybe Touch
, ... -- all other fields of Event unchanged
} This is still technically a breaking change, since we're adding another field to the |
fixes ku-fpg#96 Unfortunately this breaks every use of ePageXY
blank-canvas/static/index.html
Line 168 in 39915c1
Following https://stackoverflow.com/questions/4780837 , I can get touchstart and touchmove events with coordinates and touchend without coordinates provided I add the following to Trigger().
I am not sure why I lose the mousemove events if I leave out the
(e.type == "touchmove" || e.type == "touchstart")
The text was updated successfully, but these errors were encountered: