JakeSidSmith / react-fastclick

Fast Touch Events for React
https://www.npmjs.com/package/react-fastclick
MIT License
487 stars 41 forks source link

Preact compatibility #39

Closed mohsen1 closed 7 years ago

mohsen1 commented 7 years ago

How hard is it to make this plugin work with Preact?

@developit can you recommend a solution? I volunteer to make it work.

developit commented 7 years ago

Hmm, actually this would almost already work out of the box with Preact. It's overriding createElement, which just has to get renamed to h(). Maybe the lib could export the patch method and users call it themselves?

mohsen1 commented 7 years ago

Because Preact is not using synthetic events, overriding the native event object properties is throwing

Uncaught TypeError: Cannot assign to read only property 'type' of object '#<TouchEvent>'
mohsen1 commented 7 years ago

We were able to fix this issue by just using the original fastclick. Since it's patching the native event listeners and Preact is using the native event system it works.

developit commented 7 years ago

Nice, that seems reasonable.

developit commented 7 years ago

There's also this naive implementation I threw together a while back, though react-fastclick is much better. https://jsfiddle.net/developit/bx9vwxLt/

JakeSidSmith commented 7 years ago

I don't have any experience with Preact, so I'm not sure how possible this would be. I could spend some time looking into it, though I think I'll run into issues pretty quickly if Preact does not use synthetic events.

Unless you are happy using the original fastclick? In which case, shall I close this issue?

mohsen1 commented 7 years ago

Yes we switched to the original library. Thanks!