DEV Community

loading...

Mostly working dynamic panels in Go

progrium profile image Jeff Lindsay ・2 min read

I've been pushing forward on the port of Dan's Photoshop-like UI prototype to my web UI stack in Go. I reached the most complex code of the project, which are these dynamic panel groups. Dan split this code out into a separate project, which was a little further along than the Photoshop prototype.

This project had a bunch of simple examples I could use to see that it would work once it was ported. This took quite a while. I mostly ported it without really knowing how it all worked. I get the general idea, but I had to focus more on figuring out what types were involved and what properties a component had since none of that was explicit.

Porting to Go was rather straightforward and I just went bit by bit making sense of what was happening and then doing an idiomatic Go version. Often times this was more readable, but I also figure Dan didn't spend much time cleaning parts of this up.

Finally I finished writing the code and I started working out any inconsistencies in my interpretation of types just using the compiler errors. I ended up patching Vecty because of an assertion it makes that might not be relevant any more. Finally I could get the demo page to render without errors, but did it work?

Kinda. It's a bit unresponsive and clearly the math is off somewhere. I most likely made some mistakes implementing the algorithms. I had caught a few mistakes during the first pass, so I'm sure there's more. But the unresponsiveness made me curious about using WASM for interaction animations, like this sliding interaction. I know calling in and out of WASM is slower, but was it that bad?

I made a separate component to test drag and drop and see it perform without anything else going on. It's not terrible, but it's nowhere as smooth as native JavaScript. I read Firefox was a little ahead in speeding up calls between WASM, so I tried it there and it did seem a little smoother.

draggable experiment

Both browsers will eventually have it much faster, and for now this was tolerable. This gives me baseline for how it should behave and it's clearly not there yet. But I think it's just debugging from here.

Obviously there's more to do, but this was a fun exercise helping to fill in the gaps of my stack and get experience building real components with it. And it will be really cool to have them.

Discussion (4)

pic
Editor guide
Collapse
david_j_eddy profile image
David J Eddy

I am interested in following your progress on this. Golang + dynamic UI = winning.

Collapse
progrium profile image
Jeff Lindsay Author

I'll keep posting here and on YouTube. Let me know when you want to get involved yourself. ;)

Collapse
david_j_eddy profile image
David J Eddy

What is your Youtube, I'll give you a follow.

Thread Thread
progrium profile image