Open sibelius opened 5 years ago
I know, but to integrate hooks I have to rewrite a lot of code, moreover they are only available since React 16.8 and I don't want developers to upgrade to a new version. At the moment I don't have any plan, but let's see it in future.
https://reactjs.org/docs/hooks-intro.html#gradual-adoption-strategy
it would be cool to provide some hooks like
useZoom
, usePan
and so on, that would handle mouse events
does this integrate well with d3 zoom behavior?
It sounds interesting.... Do you think that add this hooks might require changes into the library itself or can we release it as a standalone library?
I was thinking about a new npm package called react-svg-pan-zoom-hooks... Are you interested to develop it?
it could just be exported in this package
it still share a lot of existing code already
import { useZoom } from 'react-svg-pan-zoom'
later on we can migrate the existing code to use this hooks
what do you think?
Since this is quite experimental, we could start from a standalone package and then move these features into the main. Are you available to work on it?
We can get inspiration from here https://github.com/sandiiarov/use-events
having a hook, we can reuse the same logic on react native
check this https://github.com/garblovians/react-native-svg-pan-zoom
I see. Since add hooks supports might require times (for dev and testing), I was trying to figure out a way to do this without hooks feature.
I think that, to create a react native component, you can reuse all the exported features. Look at this file https://github.com/chrvadala/react-svg-pan-zoom/blob/master/src/viewer.js The whole logic is out of this component and can be imported, using react-svg-pan-zoom as dependency https://github.com/chrvadala/react-svg-pan-zoom/blob/master/src/index.js
Just a note: I see that ./features/interactions.js and ./features/interactions-touch.js aren't exported. I'm going to fix them adding them to the export file.
Thought?
See WIP PR #152
I started rewriting the main compoments and I'll further investigate the useZoom
and usePan
idea :)
hooks would make the code simpler