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;
}
const applyOnCamera = function(props, f){
const applyOnCamera = function(props){
console.log(props);
//const camera = props.sigma.cameras[0];
//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 =
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 = runEffectFn2 applyOnCameraImpl
-- applyOnCamera :: forall a. (Nullable ReactRef) -> (a -> EventHandler) -> Effect Unit
-- applyOnCamera = runEffectFn2 applyOnCameraImpl
type SigmaProps =
( renderer :: Renderer
, settings :: SigmaSettings
, style :: SigmaStyle
, graph :: SigmaGraphData
, ref :: (Nullable ReactRef) -> Effect Unit
, ref :: SyntheticEventHandler (Nullable ReactRef)
, onClickNode :: SigmaNodeEvent -> Unit
, onOverNode :: SigmaNodeEvent -> Unit
, onOutNode :: SigmaNodeEvent -> Effect Unit
......
......@@ -209,7 +209,8 @@ render d p (State {sigmaGraphData, settings, legendData}) c =
, settings
, renderer : canvas
, style : sStyle { height : "96%"}
, ref: flip applyOnCamera <<< d <<< SaveCamera
, ref: applyOnCamera
--, ref: flip applyOnCamera $ d <<< SaveCamera
, onClickNode : \e -> unsafePerformEffect $ do
_ <- log "this should be deleted"
-- _ <- logs $ unsafeCoerce e
......@@ -534,7 +535,8 @@ specOld = fold [treespec treeSpec, graphspec $ simpleSpec performAction render']
[ sigma { graph, settings
, renderer : canvas
, style : sStyle { height : "95%"}
, ref: flip applyOnCamera <<< d <<< SaveCamera
, ref: applyOnCamera
-- , ref: flip applyOnCamera $ d <<< SaveCamera
, onClickNode : \e -> unsafePerformEffect $ do
_ <- log " hello 2"
--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