Unverified Commit a1c7ab5d authored by Mael NICOLAS's avatar Mael NICOLAS Committed by Nicolas Pouillard

[HELP] Small exemple of a working ref callback

parent 541666fa
...@@ -40,10 +40,17 @@ exports.forceLinkClass = FL.default; ...@@ -40,10 +40,17 @@ exports.forceLinkClass = FL.default;
} }
const applyOnCamera = function(props, f){ const applyOnCamera = function(props){
console.log(props); console.log(props);
//const camera = props.sigma.cameras[0]; //const camera = props.sigma.cameras[0];
//f(camera) //f(camera)
}; };
exports.applyOnCamera = applyOnCamera;
/*const applyOnCamera = function(props, f){
console.log(props);
//const camera = props.sigma.cameras[0];
//f(camera)
};
*/
exports.applyOnCameraImpl = applyOnCamera;
...@@ -254,17 +254,19 @@ type Camera = ...@@ -254,17 +254,19 @@ type Camera =
angle :: Number angle :: Number
} }
foreign import applyOnCameraImpl :: forall a. EffectFn2 (Nullable ReactRef) (a -> EventHandler) Unit foreign import applyOnCameraImpl :: SyntheticEventHandler (Nullable ReactRef)
applyOnCamera = applyOnCameraImpl
--foreign import applyOnCameraImpl :: forall a. EffectFn2 (Nullable ReactRef) (a -> EventHandler) Unit
applyOnCamera :: forall a. (Nullable ReactRef) -> (a -> EventHandler) -> Effect Unit -- applyOnCamera :: forall a. (Nullable ReactRef) -> (a -> EventHandler) -> Effect Unit
applyOnCamera = runEffectFn2 applyOnCameraImpl -- applyOnCamera = runEffectFn2 applyOnCameraImpl
type SigmaProps = type SigmaProps =
( renderer :: Renderer ( renderer :: Renderer
, settings :: SigmaSettings , settings :: SigmaSettings
, style :: SigmaStyle , style :: SigmaStyle
, graph :: SigmaGraphData , graph :: SigmaGraphData
, ref :: (Nullable ReactRef) -> Effect Unit , ref :: SyntheticEventHandler (Nullable ReactRef)
, onClickNode :: SigmaNodeEvent -> Unit , onClickNode :: SigmaNodeEvent -> Unit
, onOverNode :: SigmaNodeEvent -> Unit , onOverNode :: SigmaNodeEvent -> Unit
, onOutNode :: SigmaNodeEvent -> Effect Unit , onOutNode :: SigmaNodeEvent -> Effect Unit
......
...@@ -209,7 +209,8 @@ render d p (State {sigmaGraphData, settings, legendData}) c = ...@@ -209,7 +209,8 @@ render d p (State {sigmaGraphData, settings, legendData}) c =
, settings , settings
, renderer : canvas , renderer : canvas
, style : sStyle { height : "96%"} , style : sStyle { height : "96%"}
, ref: flip applyOnCamera <<< d <<< SaveCamera , ref: applyOnCamera
--, ref: flip applyOnCamera $ d <<< SaveCamera
, onClickNode : \e -> unsafePerformEffect $ do , onClickNode : \e -> unsafePerformEffect $ do
_ <- log "this should be deleted" _ <- log "this should be deleted"
-- _ <- logs $ unsafeCoerce e -- _ <- logs $ unsafeCoerce e
...@@ -534,7 +535,8 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render'] ...@@ -534,7 +535,8 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
[ sigma { graph, settings [ sigma { graph, settings
, renderer : canvas , renderer : canvas
, style : sStyle { height : "95%"} , style : sStyle { height : "95%"}
, ref: flip applyOnCamera <<< d <<< SaveCamera , ref: applyOnCamera
-- , ref: flip applyOnCamera $ d <<< SaveCamera
, onClickNode : \e -> unsafePerformEffect $ do , onClickNode : \e -> unsafePerformEffect $ do
_ <- log " hello 2" _ <- log " hello 2"
--logs $ unsafeCoerce e --logs $ unsafeCoerce e
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment