dundalek / markmap

Visualize markdown documents as mindmaps
MIT License
1.7k stars 175 forks source link

Dynamic width [new branch without prettier] #15

Closed khanhicetea closed 7 years ago

khanhicetea commented 7 years ago

Sorry, I forgot to commit after running prettier so it's hard to check diff. #14

I re-submit my contribution on new branch.

Thanks, have a nice day !

dundalek commented 7 years ago

Thank you so much, I will look into it. Enjoy your day, too!

dundalek commented 7 years ago

Hi, looks good. I have two comments about the code. Also there is a little bug with the collapsing / expanding animation (nodes collapse vertically but stay at the same place horizontally):

markmap-bug

In the correct original animation the nodes collapso to / expand from the parent node:

markmap-original

If these issues are addressed I think we are good to go. Thanks again.

khanhicetea commented 7 years ago

Hi @dundalek ,

I agreed your suggestion ! I fixed 2 comments above, but I couldn't fix the collapsing / expanding animation you mentioned (I am not good at JS and D3, so please help me on that). 😅

Thanks, have a nice weekend !

dundalek commented 7 years ago

Yeah, it is very confusing :smiley: For example if I change the line 59 from node.depthWidth = state.depthMaxSize[node.depth]; to node.depthWidth = state.nodeWidth; the animation starts to work correctly.

khanhicetea commented 7 years ago

Yeah, it works. But, it ignores the rule "Depth width = max width of nodes in depth" so it can makes sub-nodes of a node can show above on a sibling-node having long label.

I think the problem is we need fix on exit event ( x = (x of clicked node + its depthWidth) ), how do you think ?

dundalek commented 7 years ago

Yeah thanks, I just found a fix.

khanhicetea commented 7 years ago

👍 I tried your new fix ! It works like a charm !!!

Thank you very much 😄