Fork me on GitHub
#reagent
<
2016-03-25
>
nooga00:03:57

I’m designing node-editor type GUI (think Apple’s Quartz Composer) using reagent to render SVG and I’m trying to figure out how to represent the data. There will be draggable boxes with little round sockets, which can be connected by dragging lines between them. This means I need to track individual socket coordinates in order to render lines between them. Ideally, I’d leave that information in the DOM and access it using something like a standard DOM (.getBoundingClientRect socket-element) only when re-rendering the connections. The problem here is: how do I get socket-element (the :circle) if I render boxes this way: (defn box [b] [:g [:rect …] (for [s (:sockets b)] [:circle {… s ...}])]

nooga00:03:35

or maybe I should track coordinates inside the atom of everything and swap! them whenever boxes change?

nooga00:03:32

but I still need to get the real coordinates, whuch are calculated by svg after applying all transforms etc.

nidu16:03:55

@nooga: you can select these circles using standard document.querySelector inside :component-did-mount

nooga16:03:34

ah ok, so I just give them html ids then?

nidu18:03:51

ids or some data- attributes. Maybe React refs can be used here but i'm not sure it can be used with lists

nooga21:03:47

thanks, I’ll give it a try

afhammad21:03:19

hi, changed a bunch of stuff and now i’m getting "Uncaught Error: Assert failed: Could not find ReactDOMServer”. Using re-frame + figwheel. Can’t find the cause, any idea?

afhammad21:03:05

theres no stack trace. just points to reagents server.cljs file

gadfly36121:03:19

What version of reagent are you using?

afhammad21:03:12

fixed. but not sure how it resulted in that error message. I had a problem with logic in a ui function which returned an empty vector

afhammad21:03:38

actually still getting the error message but app is running fine as far as i can tell

afhammad21:03:47

version 0.6.0-alpha

gadfly36121:03:02

Out of curiosity try using reagent 0.5.1, doing a clean, then restarting figwheel

afhammad21:03:25

I have a component that contains a button and an input, how do I set focus on the input from the button onClick event handler?

rafd22:03:58

(reagent/dom-node this) + some js interop may be of use

afhammad22:03:43

@rafd what is this?

rafd22:03:40

you many need to use a type-3 reagent component

rafd22:03:53

wish i could help more but just got hit with a migraine

afhammad22:03:40

thanks @gadfly361 @rafd. all the examples i see are from within component-did-mount, it seems like the only way to access the dom node, which makes it tricky to access from a different element (i.e the button being clicked)