You probably found in the homepage a lossless quality waving animation. This is not a GIF, a video or a CSS animated image. It is a lottie animation that you can start using without too much setup.
On September 2021 I started one of the biggest projects I have worked on so far, not just in Factorial, but in my whole developer career. We had been redefining our new brand for months and the implementation phase was finally starting!!
We decided to tune our design system in desktop application, mobile app, public pages and our blog to be “brand friendly”. Guess who was the dev that was working on his own (aimed by designers and the brand team of course) to complete that “simple” task... 😅
Whatever, I’m deviating from the original topic. Lottie animations. One request that brand team had for the rebranding was that we change the login process on our desktop application, which currently is a bouncing logo animated with CSS. Which is fine so far, but a big change like what we were about to build needs a proper presentation for the user.
I talked about this with a Motion Designer (a completely new role for me) from Brand Studio team and he told me that he can generate some animation for me and bring me the file. And at first I thought he was talking about a GIF file, and I started wondering about things like how it would look like on different screen sizes, how to compress it to avoid delivering a monstrous file, ... But he send me a JSON file and I was like wtf 🤨
Here I discovered that Lottie files are really a thing, and they remove several layers of friction between designer and developer when working with animations:
The code to load an animation is quite simple actually, I mostly copied this answer from user Danila in StackOverflow. You only need three main things to make this work:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import type { LottiePlayer } from 'lottie-web'
export const LottieLoader = ({
animationName,
loop = true,
autoplay = true
} : Props) => {
const ref = useRef(null);
const [lottie, setLottie] = useState<LottiePlayer | null>(null);
useEffect(() => {
import('lottie-web').then(Lottie => setLottie(Lottie.default))
}, []);
useEffect(() => {
if (lottie && ref.current) {
const animation = lottie.loadAnimation({
container: ref.current,
renderer: 'svg',
loop: loop,
autoplay: autoplay,
path: `/lotties/${animationName}.json`
});
return () => animation.destroy();
}
}, [lottie, animationName, autoplay, loop]);
return (
<div ref={ref} className={cn(
'items-center',
configWidth[animationName] // To avoid flickering
)}/>
)
}
This post is created thanks to many people, so I want to thank them individually: