Wednesday, May 19, 2021

How to Build a Coming Soon Page With Lottie Animations

How to Build a Coming Soon Page With Lottie Animations
Final product imageFinal product imageFinal product image
What You'll Be Creating

In a previous tutorial, we learned how to include Adobe After Effects animations on a page using the Lottie for Web library. Today, we’ll learn how to repeat this process using the LottieFiles web player.

Our final goal will be to build a coming soon page that will contain three different Lottie animations Shall we start?

Our Coming Soon Page

Here’s the coming soon page that we’re going to create during this tutorial:

Be sure to view the demo on different screen sizes and check how the page layout changes accordingly.

1. Begin With the Required Assets

For this exercise, we’re going to need some assets.

Grab a Web Font

First, we’ll grab a custom web font from Envato Elements.

FRANK - FONT PACK on Envato ElementsFRANK - FONT PACK on Envato ElementsFRANK - FONT PACK on Envato Elements
FRANK - FONT PACK on Envato Elements

Grab Some Lottie Animations

Then, we’ll grab some of the many free Lottie animations from the LottieFiles library:

Customize the Animations

LottieFiles gives us the ability to customize the animations according to our needs. On the right side of the animation’s main page there’s a panel with different customization options.

Note: we won’t go through all of them, you can do that on your own time! Here we’ll focus our attention on two of them.

The customization options for a Lottie animation

Our animations will be used on an HTML page. So, let’s select the <html> option from the panel.

Selecting the html option from the panel

This will open a new page where we can configure the appearance of the associated animation. Based on our selections, the markup of the lottie-player web component will be modified appropriately. This is the component that stores the animation details. Our page will include three animations, therefore we’ll add three such components to our HTML later on.

Configuring the web playerConfiguring the web playerConfiguring the web player

Editing Lottie Animations

But what if we want to edit the animation colors? If you carefully look at the demo, you’ll notice that the arrow and Twitter colors are different from the animations’ initial colors.

To do this we have to go back to the right-hand panel and select Edit Layer Colors for the target animation.

Selecting the Edit Layer Colors option from the panel

This will open a new page where we can configure the color(s) of the associated animation. 

Customizing twitter's layer colorsCustomizing twitter's layer colorsCustomizing twitter's layer colors

After selecting the desired color(s) and hitting Update, we then have to export the animation as JSON. This JSON will now include the new color(s).

Exporting the Lottie animation after modificationsExporting the Lottie animation after modificationsExporting the Lottie animation after modifications

Preview Lottie Animation

Next, we’ll use Lottie Preview, another tool from LottieFiles, for previewing the animation. This will give us a new shareable URL of the animation that we’ll use to replace the one that appears on the src attribute of the related lottie-player component.

Previewing the new animationPreviewing the new animationPreviewing the new animation

2. Include the Lottie Player JavaScript

Coming up next, we’ll include the required Lottie Player JavaScript file in our project:

The required JavaScript file for Lottie PlayerThe required JavaScript file for Lottie PlayerThe required JavaScript file for Lottie Player

It’s worth mentioning that this script will appear above the lottie-player component each time we select the <html> option from the right side of the animation’s main page.

The required LottieFiles JvaScript scriptThe required LottieFiles JvaScript scriptThe required LottieFiles JvaScript script

3. Define the HTML Markup

Our page will consist of:

  • A title
  • A subtitle
  • A signup form that will normally be integrated with a marketing platform like MailChimp. Also present on this form will be the arrow animation.
  • An under-construction animation
  • A link to the company’s Twitter account with the Twitter animation.

Here’s the associated markup:

Notice the three lottie-player components. Some things to note:

  • The arrow and under-construction animations will play infinitely by default.
  • The Twitter animation will play on hover.
  • We won’t define a width and height for the under-construction animation through HTML. As its size will depend on the screen dimensions, let’s specify it through CSS.
  • As described in the previous section, we’ll customize the color of the arrow and Twitter animations, so we’ll pass to the related lottie-players a different URL compared to the generated one. Remember that we used the Lottie Preview tool for this action.
  • We’ll tidy up the produced code for the lottie-players by removing the default options like background="transparent" and speed: "1".

4. Define Some Basic Styles

With the markup ready, we’ll continue with some reset styles. Most importantly, the page height will have a minimum height equal to the viewport height. This will help us produce a fullscreen experience on large screens. Still, if necessary a vertical scrollbar will appear.

Here are the styles:

5. Specify the Main Styles

As already mentioned, the page layout will look different depending on the viewport size.

Let’s be more specific.

  • On screens up to 1199px wide all elements will be stacked.
  • On screens up to 767px wide we’ll position the Twitter animation in the bottom right corner of the page.
  • On screens wider than 1199px we’ll have a two-column layout.
  • On screens wider than 767px we’ll position the Twitter animation in the top right corner of the page.
The page layout on screens wider than 767pxThe page layout on screens wider than 767pxThe page layout on screens wider than 767px
  • On screens that are at least 1500px wide we’ll position the form button next to the input element.
The page layout on screens wider than 1500pxThe page layout on screens wider than 1500pxThe page layout on screens wider than 1500px
  • Last but not least, we’ll apply different hardcoded dimensions for the under-construction animation concerning the viewport dimensions.

With all the above in mind, here are all the associated styles:

As ever, the best way to understand these styles is through your browser’s inspection tools.

Conclusion

Done, folks! Today, we built on what we learned in a previous Lottie tutorial and examined the steps needed for adding Lottie animations to a web page using LottieFile’s web player. We only covered some basic things, so be sure to dig into the documentation and try to implement something more advanced.

As we saw, LottieFiles provides (thanks team!) several helpful tools (e.g. Lottie Preview and Lottie Editor) for customizing the animations on the fly without having to manipulate them on Adobe After Effects. You can take advantage of them either by using a community-made animation on LottieFiles or a custom one (assuming that you have it in JSON format). 

If you’re interested in exploring more Lottie demos/examples related to different technologies, check out my published articles on LottieFiles.

Here’s a reminder of what we built:

As always, thanks a lot for reading!


No comments:

Post a Comment