Skip to main content
<CodeWithBhurtel/>
HomeLearnProjectsChallengesBlogAboutContactLogin
<CodeWithBhurtel/>

Learn through structured lessons, real projects, and live challenges. Free tutorials for HTML, CSS, JavaScript, and more.

Pages

  • Home
  • Learn
  • Blog
  • Projects
  • Challenges
  • About
  • Contact

Lessons

  • HTML
  • CSS
  • JavaScript

© 2026 CodeWithBhurtel. All rights reserved.

Privacy PolicyTerms & Conditions
Projects

Drone Style Order Button Animation

IntermediateCSS, HTML, JavaScript

Drone Style Order Button Animation – project preview
Share this project
Follow me on social media

Understand with AI

Get an AI-generated overview or a file-by-file code breakdown. Ask questions about the project below the overview.

AI Overview: Drone Style Order Button Animation

This project is a creative micro-interaction for a web-based "Order" or "Checkout" button. Instead of a standard loading spinner, it uses a playful animation where a drone appears to pick up a package from the button, fly it across the screen, and deliver it. This visual narrative keeps users engaged during the "processing" phase of a transaction, turning a functional wait time into an entertaining experience.

The project is built using a combination of SVG graphics for the drone and package, CSS for the complex animations, and a small amount of JavaScript to trigger the sequence. The animation is broken down into distinct stages: takeoff, horizontal flight, landing, and a final "Delivered" state. Each stage is carefully timed using CSS transitions and keyframes to ensure the movements look fluid and coordinated.

Key Code Snippets

1. Triggering the Animation
The JavaScript doesn't handle the animation frames; instead, it acts as a "state switcher" by adding a CSS class to the main container when the user clicks the button.

$demo.addEventListener('click', () => {
  if (processing) return;
  processing = true;
  $demo.classList.add('s--processing');
  // ... logic to reset after 10 seconds
});

This snippet ensures that the animation only starts if it isn't already running and applies the .s--processing class to start the CSS sequence.

2. Independent Movement Containers
To make the drone's flight path easier to manage, the HTML uses nested containers. This allows the developer to animate vertical movement (takeoff) and horizontal movement (shifting) separately.

<div class="demo__drone-cont demo__drone-cont--takeoff">
  <div class="demo__drone-cont demo__drone-cont--shift-x">
    <div class="demo__drone-cont demo__drone-cont--landing">
      <!-- Drone SVG goes here -->
    </div>
  </div>
</div>

By nesting these divs, the CSS can apply a translateY for takeoff on one layer and a translateX for forward flight on another without them interfering with each other.

3. Sequential Text Updates
The button displays different messages (Processing, Delivering, etc.) using a CSS keyframe animation that moves the text up and fades it in and out at specific intervals.

@keyframes textAnimation {
  20%, 80% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-20px);
  }
}

This CSS rule is applied to the different text steps, using animation-delay to ensure "Processing" disappears just as "Delivering" begins to show.

How It Works

When the .s--processing class is added, the CSS takes over. It uses stroke-dashoffset to animate the circular progress bar and transform properties to move the drone SVG. The "grabbers" on the drone are animated to close around the package icon, which then moves upward simultaneously with the drone to simulate a pickup. Finally, after a set duration, the JavaScript removes the processing classes to "revert" the button back to its original state, ready for another click.

Ask about this project

Have a question about how this project works? Ask below and get an answer based on the project code.

Code Breakdown

Structured technical breakdown for beginners. Anyone can generate or regenerate; your version is saved in this browser (local storage).

No breakdown yet. Generate one to see a file-by-file explanation. Your version is saved in this browser.

Comments

No comments yet. Sign in to leave a comment.

Sign in to leave a comment.