Instagram-Style Like Animation 🥇
Rodrigo Antunes

Rodrigo Antunes @rodrigoantunes

About: Front-End Engineer

Location:
Brazil
Joined:
Jan 19, 2023

Instagram-Style Like Animation 🥇

Publish Date: Aug 5 '24
10 6

This is a quick way I found to congratulate Brazil's top Olympic medalist, Rebeca Andrade, and, of course, share something I learned during the making of this effect.

Double click below to see the effect 🪄

HTML

The markup is pretty straightforward, so I don't think there is much to say, other than highlighting the semantic use of HTML elements for structure and clarity, and the use of <strong> tags so you don't have to handle it in the CSS.

CSS

I noticed there is a little random direction of the rotation every time the effect runs, so I passed a dynamic value to the CSS, similar to how we do with props in React.

.heart {
  animation-name: like;
  animation-duration: 1s;
  animation-fill-mode: forwards;
}

@keyframes like {
  0% {
    opacity: 0;
    transform: scale(0)
  }

  40% {
    opacity: .8;
    transform: scale(1.2) rotate(var(--random-rotation-deg))
                   /* dynamic value here 👆 */
  }

  60% {
    opacity: 1;
    transform: scale(1)
  }

  100% {
    opacity: 0;
    transform: scale(.9) translateY(-500px)
  }
}

Enter fullscreen mode Exit fullscreen mode

Javascript

Here's how I created the element, give it the .heart class (which contains the animation-name), and generated the random-rotation-deg value.

const image = document.querySelector('.image');

// listen for the 'dblclick' event
image.addEventListener('dblclick', () => {
  const rotation = Math.floor(Math.random() * 80) - 40;
  // this function returns a value between -40 and 40

  const heart = document.createElement('div');
  heart.classList.add('heart');
  heart.textContent = '🩷';
  heart.style.setProperty('--random-rotation-deg', `${rotation}deg`);
  // then, I pass this value so it can be read inside the CSS

  image.appendChild(heart);
  heart.onanimationend = () => heart.remove();
});

Enter fullscreen mode Exit fullscreen mode

This method dynamically creates a heart element on double-click, applies a random rotation to it, and animates it using CSS keyframes.

For asset management, I'm using Cloudinary which offers 25 GB of storage in the free plan — more than enough for small projects.

Once again, Congratulations to Rebeca Andrade, Simone Biles and Jordan Chiles.

Comments 6 total

  • Colby Fayock
    Colby FayockAug 6, 2024

    killer! and she was fantastic 👏

    • Rodrigo Antunes
      Rodrigo AntunesAug 6, 2024

      Thank you! 😊 She truly was amazing! 🤸🏾‍♀️

  • Charles Jordan
    Charles JordanSep 14, 2024

    Instagram-Style Like Animations bring an engaging touch to social media, making interactions feel more lively and rewarding. As platforms like Instagram grow increasingly dominant, having a strong follower base becomes essential for online credibility and outreach. Services like Twicsy allow users to purchase followers, offering an instant boost in visibility and engagement.
    Similarly, apps like Instagram Followers Apk and Top Follow Apk App provide tools to grow follower numbers. However, it's important to use these services wisely to avoid violating Instagram’s terms. Ultimately, a mix of real followers and genuine engagement is key to long-term success on Instagram.

  • Brayden Anderson
    Brayden AndersonSep 20, 2024

    Ready to boost your social media presence? Discover TopFollow Apk App
    , the ultimate app for growing your follower base organically! Whether you're a budding influencer, a small business owner, or just looking to connect with like-minded individuals, TopFollow Apk App has everything you need.

    With its user-friendly interface, you can easily explore trending content, engage with your audience, and make valuable connections. The app offers powerful features like automated follower management and targeted engagement tools, all designed to help you grow your profile effectively.

    Plus, TopFollow Apk App provides insightful analytics to track your progress and refine your strategy. Best of all, your privacy and security are our top priorities, ensuring a safe experience while you expand your online presence.

    Download TopFollow today and take the first step towards becoming a social media superstar!

  • Protopfollow
    ProtopfollowDec 21, 2024

    TopFollow APK is a free app that allows users to gain unlimited followers on social media platforms like Instagram and Twitter. By providing an easy-to-use interface and powerful tools, TopFollow helps boost your online presence and increase engagement. With this APK, users can enhance their social media profiles quickly and effectively, attracting more followers without any cost. Whether you're looking to grow your personal brand or expand your social influence, TopFollow offers a seamless solution for increasing followers and improving visibility. Download the TopFollow APK today for free and start boosting your social media presence!

  • Jamil Ahmad
    Jamil AhmadJan 21, 2025

    Instagram-like animations make interactions more engaging while growing a solid follower base is key for online success. Services like Twicsy and apps like Instagram Followers Apk can boost your visibility, but it’s important to use them responsibly to avoid breaking Instagram’s rules. The best approach is a mix of real followers and authentic engagement for long-term success.

Add comment