a library combine react-native-web and preact together
Usage no npm install needed!
<script type="module">
import preactResponderEventPlugin from 'https://cdn.skypack.dev/preact-responder-event-plugin';
</script>
README
preact-responder-event-plugin
This library implement the react native's Gesture Responder System which is required by react-native-web.
It brings the preact and react-native-web together like what react-dom does for react and react-native-web. Now you can build a react native app into web app by using preact.
It's 3KB after compressed, no need to worry about the size.
Installation
It depends on preact 10 and react-native-web, so you need to install them too.
npm i preact-responder-event-plugin react-native-web preact@next
The plugin will listen to some events like touchstart, touchmove at document node like the react do.
It will find those views which want to be the responder(if a view has an onStartShouldSetResponder or onMoveShouldSetResponder property) and pick the first one to be the responder when start or move events being triggered
If another view, like a parent view, also wants to be a responder. the plugin will call responder's onResponderTerminationRequest to ask if it allows the request. if it returns true, the responder will be transferred to another view.
If it's a multi-finger touch, the responder view's onTouchEnd will be called when the touchend event is fired and when the event.touches becames zero, onResponderRelease will be called.
On desktop platform, a mouse event will transform to a touch event and it will be treated like a single-finger event.