Example in readme does not run. #24
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Running the example in the readme will result in "node.layout is undefined" error.
This doesn't occur in the tests because of the preprocessing the node goes through in the testing suite. Particularly in the computeCSSLayout function.
I'm not sure if this is the expected behavior for the library or if the preprocessing should be moved internally, but either way the readme example should change to reflect this.
This is how I run them 😄
Woops. We're not actually using the JS version anywhere so the code isn't in a very good shape. Wanna submit a pull request to make it cleaner?
I was just about to raise exactly this issue! The
computeLayout
function relies on the nodes having alayout
property. This is ensures within the tests as a result of thefillNodes
function.Personally I think the API would be better if
computeLayout
was a bit more flexible - adding thelayout
property if it is not already present.@ColinEberhardt: happy to take pull requests to improve the JS API. It's indeed not great in the current form
@vjeux - I'll see what I can do :-)
By the way, I'm using code from this project to apply flexbox layout to SVG - it's great for creating chart layouts. You can see this in practice here:
http://www.scottlogic.com/blog/2015/02/02/svg-layout-flexbox.html
Thanks for making this open source.
There seems to be more missing pieces, like text sizing. At the moment these are hardcoded in tests, and rely on some iframe hack to get initial values.
@Dashed: in the test files there's a function that is able to measure text. Unfortunately, the browser support for that is pretty bad. You can either use canvas, but then you don't have line wrapping, or create a dom node yourself but it's pretty slow.
@ColinEberhardt this is really exciting, thanks for letting me know :) I had no idea that anyone else would be using it to do interesting things
I would like to try and fix the bug?
The layout will fail if a child miss "style" attribute cf. https://gist.github.com/amirouche/c756a6bb4de2aa95e958#file-app-js-L18
the workaround for now is to use @jimmyhmiller's fork that includes the fillNodes function in the library and exposes it, it would be better to also have the extractNodes from @Dashed in there as well so that the result is consistent with what the README says the output will be…
So, here is what I am doing as a workaround for using css-layout in a javascript project:
Then, in the javascript:
My goal is to have my repo in a state where I can make a pull request this weekend. I'm hoping to have some time Sunday to work on it.
+1 @jimmyhmiller @Dashed @ColinEberhardt
Glad I found this issue -- we'd like to use css-layout from clojurescript so a fix for easier use from JS is most welcome!
Since my PR was merged this example now runs. @pandeiro let me know if there is anything you find you. I'm excited to see what everyone is building with this, got some ideas myself.
@jimmyhmiller Thanks for the refactor 👍
was the PR merged?