nolanlawson / pinafore

Alternative web client for Mastodon (UNMAINTAINED)
https://pinafore.social
GNU Affero General Public License v3.0
1.02k stars 176 forks source link

Content warning animation is low-framerate #7

Open nolanlawson opened 6 years ago

nolanlawson commented 6 years ago

This looks janky, especially on mobile Firefox. The built-in svelte-transitions slide animation animates height rather than transform.

sorin-davidoi commented 5 years ago

I think this can be closed, display: none seems to be used now.

nolanlawson commented 5 years ago

Yes this is about as fast as it can possibly get.

nolanlawson commented 5 years ago

Ah wait no, the issue is the animation itself. It animates properties that force style/layout, rather than ones that can run on the GPU (e.g. transform).

nolanlawson commented 5 years ago

I had a go at fixing this but I'm not sure how possible it is. The GPU-accelerated animation would require two things:

So I'm not sure how practical it is to fix this. We could try switching to fade in/out animation, but I found it kind of ugly.

Krinkle commented 4 years ago

If I understand correctly, the complication here is that transform can't be trivially used over height because you need the space to be reserved when in the expanded state (as normal static position/flow would) and given up to other elements before/after the current one when in the hidden state.

Assuming that's right, then using the FLIP principle might help.

The FLIP idea is: Use height during the setup of the animation (forced-computed via getBoundingClientRect, but never visually rendered), then leave height alone and let transform smoothly animate it from there. See more at https://aerotwist.com/blog/flip-your-animations/.

The main difference between this and plain height animation is that the space will be reserved at once and then taken up by the animation. If it is a design requirements that further elements move down pixel-by-pixel unison with the current element being expanded, then a non-janky implementation is pretty much impossible today. – For that, I think animating height is the simplest and most easy to reason about way to accomplish that.

nolanlawson commented 4 years ago

@Krinkle Thanks Krinkle, I'm aware of the FLIP method and I actually tried to implement this, but the additional problem is that there are multiple elements on the page that would need to move simultaneously, so each one would have to be FLIPed. I actually did implement this and then realized that I wasn't accounting for the border-bottom on statuses when you're replying to a toot and have to animate the reply box within a status (which should cause its border-bottom to animate down as well as every status below it).

I really need to write a blog post or something about how we need a new web API for this, because it's just way too difficult to implement manually.