Building Better Interfaces with SVG (2015)
slides.com
slides.com
- Poor optimisation. Browsers have done a lot to speed up HTML + CSS rendering via the GPU, and you can you use WebGL to make canvas fast. SVG seems to have been neglected in comparison.
- No layout management. HTML + CSS isn't perfect in this regard, but you still get blocks + inline text, floats, absolute positioning, tables and flexbox (and soon, grids). In SVG, you get absolute positioning, and that's it. If you want to do any kind of complex layout, you have to calculate everything yourself in script.
I'm not sure the major browser vendors really care too much about SVG. Compare the huge advances made in other areas of the web platform with the years-long, incredibly unambitious SVG 2 specification process.
It's a real shame as as this presentation shows, you can do some incredible stuff with SVG. But it could be so much more if there was just a bit more effort invested.
So unless there is excellent support (can make animations, generates nice code,..) by Adobe products it wont catch on.
What is absolutely terrible is dealing with SVGs exported from Sketch. And that's all our UX/UI/Designers use these days.
Hackers and Painters: http://paulgraham.com/hp.html
However we have used Sketch's SVG export for things like icons, and I've found it to be pretty good. There's even an CLI export tool than you can integrate into your build process.
CSS/SVG is used for websites.
Think loading times are bad on script-heavy websites now? Wait until every web app uses its own mix of graphics, font and layout libraries, all compiled from C/C++ to WebAssembly and shipped in a 100MB blob. And rendered without any integration with accessibility technologies, and with basic things like copy and paste disabled to stop you "stealing" content. No thanks.
SVG 2 leaves the "painter model" behind (where z-order is determined by document order of the respective shape within its container) in favour of the z-index CSS property, so that you can address it in CSS (eg. `:selected { z-index: 1 }`). This makes it possible to describe things like interactive maps and DVD-like menus where when you click on a shape, the shape gets scaled or applied some other transform for highlighting.
However, I agree that SVG 2 leaves a bit to be desired (for example, level of detail properties). Also, animation of SVG in FF sucks compared to Chrome and Safari, or at least it used to 3 years ago. I wanted to teach my 12-year old how to make a simple browser game, but had to resort to hackish workarounds to make it run smoothly on top of using rAF etc., ruining my pedagogical ambitions.
I can relate to this, I use to work on a svg-heavy project in 2014 and I had the same kind of issues and I filed many bugs on FF bug tracker .
Fortunately, they've all been fixed by the mid of 2015. I don't work with svg so I don't know if everything works well now, but at least there were improvements.
Time will tell though.
My work involves working with huge svg documents (up to 500k Dom nodes) with a relatively well defined structure so there are lots of bits of svg that I'm less familiar with. Because I'm fairly sensitive to performance issues I've seen the work that goes on there and you're right, it's second class compared to html but there's still development happening.
The layout management is definitely substandard. It's a bit of a kludge but you can use foreignobject to put HTML inside svg and do the layout there. On paper it doesn't look too bad [0] but YMMV and I haven't played with it myself.
All in all I'd like to see more activity in the svg space. It's a great tool and with a bit more awareness I think it could have a great future in the web development world.
Performance is good! I've definitely had to come up with some pretty clever hacks but it feels smooth once the SVG has loaded. In our case we need to be able to zoom in to arbitrary levels and still have crisp vectors.
Here's an example of a document with about 150,000 dom nodes. You'll see that it's a little sluggish when you're zooming in and out but after it catches up it's really quick to move around. Most of our documents are much smaller than this so there's no real delay on zoom in those cases.
https://dl.dropboxusercontent.com/u/233998/example_movement....
Generally speaking when you have that many elements, you've surpassed the threshold of what SVG is intended to do. Canvas can be a seamless replacement for SVG without any tradeoffs, other than additional build complexity
Yeah, the machine is definitely going to make a difference, though as I say a) most our documents are smaller than this and b) we have ways of speeding up bigger documents where required.
Sure, SVG isn't made for this, but it works. Going to canvas would mean a load of extra work and you can be sure there would be other tradeoffs and issues to work around. Additionally, SVG is super hackable. You can work with it easily front and back end. You can read it and understand what's going on.
And hey, if your users are happy.... :-)
http://www.capterra.com/takeoff-software/spotlight/144811/Co...
Given that svg 100% works for my usecase, I don't have any reason to attempt anything else at the moment. People give svg a hard time about performance and I think that's counterproductive. My suggestion is that everyone should give it more of an honest shot and I suspect they'll find that there are plenty of cases when it becomes the first tool they reach for.
[0] http://stackoverflow.com/questions/19284304/how-redraw-on-ca...
But then we got a requirement to overlay a line chart on the bars. And that meant layering a separate SVG on top, and doing a bunch of script work to make sure everything lined up correctly. E.g. detecting when the window resized, or when the content overflowed, etc.
It worked, but the resulting code is not at all fun to work with. The frustrating thing is the that the layout is trivial in pure HTML + CSS, and the graphics are trivial in pure SVG. But neither has the complete story, and so you end up having to jump through so many hoops, when it feels like it could be so much easier.
Depends on what you mean by absolute. The current transformation matrix (CTM) in each group hierarchy is computed relative to the parent element.
It might be fine for showing technical flexibility, but they do not add to interaction; they are distracting, slow down responsiveness, and worse, are non-standard and unexpected. I hope this kind of stuff doesn't catch on.
I like to call this trend "Flanders Computing" -- where developers and designers increasingly create obnoxiously friendly websites and apps that treat you as if they're your diddly-doodly buddy-ol-pal.
A recent Windows 10 install told me "We're happy you're here!" Who exactly is "we" and why are they trying to be all buddy-buddy so soon? I assume the market research told them that this was the best start screen, but good grief is all the wiggly-wobbly buddy-ol-pal stuff so friggin annoying. It's like forced intimacy that can't be reciprocated, which feels weird.
Love your idea for the Flanders Threshold. Hit me up any time at john@cheesierthanaripecamembert.com and tell me what you need. I'll be more than happy to help.
Looking forward to making magic with you on the Flanders Threshold, cha-cho!
Best,
John
CEO/Sales/Customer Support*
Cheesier Than A Ripe Camembert, Inc.
(Every time I get a mail like this from some trendy tech firm, I die a little inside, but somewhere in the past year or two I think they all read the same book and now they're all doing it.)
I also experienced that moment of "oh shit!". I've rarely used Windows in my life, but when I have, when Windows blanks the display and pops up something like that and isn't booting, it's historically something scary.
I think Google's Material Design strikes a good balance regarding use of animations. They sometimes have very elaborate animations, but usually in very small areas where the animation becomes an easteregg rather than an annoyance. (For example, how the hamburger menu icon transforms into the back-arrow and vice versa. Or, on the Android notification panel, how the cogwheel rolls away as it fades out. That's cute.)
It can be time consuming at the beginning, but once you get the hang of it, you won't use anything else.
The big problem when doing layouts for SVG outside of a browser is determining the bounding box for text. The best I can do is get a box from Pango and hope browsers render text close to the same way.
(Ps, I now know the murky details of exactly how Firefox, chrome and Inkscape calculate their bounding box and clientBoundingRect, which is sort of sad but just the life of a coder I guess)
It would be amazing to be able to load an SVG icon as an image with a class, and then be able to use CSS to manipulate the image (change the colour etc) but know the image is cached by the browser.
If you inline using JS, you can use standard styling / classes to modify the display. Since it happens via standard browser requests, you get normal caching behaviour. One bad thing though is that you have to wait for the JS to execute, so there may be some blinking.
<svg><use xlink:href='#svg-id'></use></svg>
Here's a quick example I threw together: http://syd.jjcm.org/svgCacheTestIf you click on the folder icon you can see it being changed by the css.
I bet you could do some kludgey stuff to get it to load. An idea that springs to mind is to include your svg as an image in the page (but hidden, like a sprite map) and then use the 'use' tag referencing ids in the hidden image wherever you wanted to place the sprites.
Either way, you currently have to work around a (seemingly arbitrary) restriction with browsers not allowing CSS on svg images.
ImageTracer is a simple raster image tracer and vectorizer, 100% free, Public Domain.
Available in JavaScript (works both in the browser and with Node.js), "desktop" Java and "Android" Java:
https://github.com/jankovicsandras/imagetracerjs
Was particularly enamored with slide 41: http://slides.com/sarasoueidan/building-better-interfaces-wi...
I think most of the animations on that slide are not-distracting, and intuitive UI elements (except the chat box on the right).
I picture myself typing this on my phone, letting it rest on the desk unlocked while continuing to read HN, but finding myself constantly disturbed by these bouncing waterdrops in my peripheral vision.
But I'm also against read receipts and showing when the other person is typing at all, so I figured maybe this is what people are into these days
> SVG text is fully accessible, searchable, selectable and 100% semantic.
Only if you don't convert the text to paths, which is really really common in the wild because someone wants a specific font or text positioning. Supposedly you can create invisible text for that purpose but I've only seen it once in a real SVG.
- SVG icons are more complicated to drop in, or complicate the code. For icon fonts it's usually just a CSS class, which is lean and expressive. For SVG, either I drop in the explicit code, which can be huge and hard to read, or I include it as external file (like an image) and lose CSS styling abilities.
- Versioning is harder. SVG icons are usually present as files, either from a thrid-party set or created and maintained using editors like inkscape. Now I either copy the code for above styling advantages, which is obviously bad for consistency, or I reference them as external images and lose stlying power again.
Are there any good workaround for those issues?
If you want to make impressive visualizations in very little code, I suggest you look at d3js. Here's the start of a series of fantastic tutorials done by Mike Bostock, founder of d3: https://bl.ocks.org/mbostock/3808218
I'd suggest you try that example out in http://blockbuilder.org/. I have no affiliation but it makes playing with d3 easy. After that, peruse the articles on the third example, find cool examples on bl.ocks.org, and replicate them.
A few things to note starting out(I've been learning d3 lately):
- v4 was a breaking change from v3, some v3 examples may not work out of the box but mostly will. If the >1MB bundle size of v3 scared you away, v4 is all es6 modules so you pay for what you use.
- the data model is enter-update-exit, its elegant but can take some time to understand.
- d3 looks procedural at first but is actually declarative if you follow the idioms.
- if your code keeps adding elements when it shouldn't, you probably messed up either a select/selectAll somewhere or forgot to add a class/id to the element when creating it.
- using typescript with d3 feels great but there are some gotchas; if you're interested, let me know and I'll write a blog post.
I do realize the slides are about interfaces with svg, so d3 may not be exactly what you want but damn if it isn't worth mentioning here.
This would be extremely interesting and useful. Please do write your thoughts about it. Thanks.
The claim of svg being semantic is laughable when i see one of the examples leverages the "d" attribute of an svg element.
Anyone doing work with d3 is eminently appreciative of the abstraction it provides for working with svg. There isn't an analog for working with css
Google Chrome 54.0.2840.100 (64-bit Ubuntu)
http://slides.com/sarasoueidan/building-better-interfaces-wi...
And Mike seems to have a rather practical approach, while Sara is the only SVG evangelist out there.
I like her stuff, it's sad that SVG doesn't get more love.
Done properly, should work great.