Animating SVGs

Building an Interactive FIFA Skills Trainer with SVG Animations

As a developer passionate about both coding and football, I wanted to create something that combined my love for both worlds. That's how my FIFA Skills project was born – an interactive web application that teaches FIFA controller tricks through animated SVG controllers.

The Vision

The concept was simple but ambitious: show animated controller inputs on one side of a card, and display the corresponding FIFA skill move on the other side. Users could click cards to flip between the controller animation and the actual skill demonstration. With dozens of skills to showcase, I needed a smooth infinite scroll experience to handle the content.

Why SVGs for Controller Animations?

When I started this project, I had a few options for creating the controller animations:

  • Canvas-based animations

  • CSS animations with DOM elements

  • SVG-based approach

  • Video files

I chose SVGs for several compelling reasons:

Scalability and Performance

SVGs are vector-based, meaning they look crisp at any screen size without losing quality. Since my app needed to work on everything from mobile phones to large monitors, this was crucial. The controllers needed to remain sharp and detailed regardless of the device.

Precise Control

Each controller element (buttons, sticks, triggers) needed to be individually animatable. SVGs gave me the granular control I needed – I could target specific paths and elements with CSS and JavaScript, creating smooth transitions for button presses and stick movements.

Small File Sizes

Compared to video files or image sequences, SVGs are incredibly lightweight. My entire PlayStation controller SVG, complete with all its components, weighs in at just a few kilobytes.

The SVG Architecture

I broke down each controller into modular SVG components:

// Each controller part is its own component
<PlaystationControllerWrapper>
  <LittleButtons />
  <PlaystationControllerLeftStick />
  <PlaystationControllerRightStick />
  <PlaystationControllerButton />
  <PlaystationButtons />
</PlaystationControllerWrapper>

This modular approach meant I could animate individual elements independently. For example, the left stick component (PlaystationControllerLeftStick.tsx) is just a series of SVG paths that can be transformed and animated:

<path
  d="M214.725 170.668C214.752 158.847..."
  fill="#222222"
  stroke="black"
  strokeMiterlimit={10}
/>

Animation System Design

The real magic happens in my animation orchestration system. I created a fluent API that lets me define complex controller sequences:

new ControllerAnimation("Directional Nutmeg")
  .animate(ControllerElement.leftBackButton, true)
  .then(ControllerElement.rightStick, stickMovements.right, { 
    duration: 1, 
    delay: 0 
  })
  .get()

This system handles:

  • Timing coordination

    : Each animation step knows when to start relative to previous actions

  • Element targeting

    : Precisely control which controller parts animate

  • Smooth transitions

    : CSS transforms handle the actual visual changes

The StickMovements class generates the coordinate transformations for analog stick rotations:

export const stickMovements = {
  right: new StickMovements().right().done(),
  rightRotate45: new StickMovements().right().rotate(45).done(),
  rightRotate360Long: new StickMovements().right().rotate(360).left().done(),
};

Framer Motion Integration

I integrated Framer Motion to handle the smooth SVG animations. This gave me:

  • Hardware acceleration

    : Animations run on the GPU for buttery smooth performance

  • Spring physics

    : Natural-feeling button presses and stick movements

  • Complex choreography

    : Multiple elements can animate in coordination

The result is controller animations that feel responsive and realistic, mimicking the actual tactile experience of performing FIFA skills.

Infinite Scroll Implementation

With 40+ FIFA skills to display, I needed a performant scrolling solution. I used react-infinite-scroll-component for several reasons:

Performance Benefits

Instead of rendering all 40+ cards at once, infinite scroll only renders visible cards plus a small buffer. This keeps the DOM lightweight and maintains smooth scrolling performance.

User Experience

The infinite scroll creates a Netflix-like browsing experience. Users can continuously scroll through skills without pagination breaks, maintaining their flow state while learning.

Memory Management

As users scroll past cards, they're removed from the DOM, preventing memory bloat during long browsing sessions.

The Card Flip Animation

Each skill card has two states:

  1. Front

    : Shows the animated controller with the required inputs

  2. Back

    : Displays the actual FIFA skill move (GIF or video)

I implemented this with a simple state toggle and conditional rendering:

const [isRotated, setIsRotated] = useState(false);

return (
  <section onClick={() => setIsRotated(!rotated)}>
    {!isRotated && <ContentFront />}
    {isRotated && <ContentBack />}
  </section>
);

The CSS handles the smooth flip animation, while the SVG controller animations continue running on the front side.

Technical Challenges and Solutions

Challenge 1: Animation Synchronization

Problem: Multiple controller elements needed to animate in perfect sequence. Solution: Built a timing orchestration system that calculates start times relative to previous animations.

Challenge 2: SVG Responsiveness

Problem: Complex SVG controllers needed to scale properly across devices. Solution: Used responsive viewBox attributes and percentage-based sizing.

Challenge 3: Performance with Many Cards

Problem: Rendering 40+ animated cards simultaneously caused performance issues. Solution: Implemented infinite scroll with lazy loading and DOM cleanup.

Results and Impact

The final application delivers:

  • Smooth 60fps animations

    even on mobile devices

  • Intuitive learning experience

    that visually connects controller inputs to skills

  • Scalable architecture

    that easily accommodates new skills and controllers

  • Cross-platform compatibility

    from phones to desktops

Key Takeaways

  1. SVGs are perfect for interactive UI elements

    that need to be scalable and animatable

  2. Modular component architecture

    makes complex animations manageable

  3. Performance optimization

    is crucial when dealing with multiple animated elements

  4. User experience

    should drive technical decisions – the flip card interaction makes learning more engaging

The project proved that with the right architectural decisions, you can create rich, interactive experiences that are both performant and educational. SVGs, combined with modern React patterns and animation libraries, provide a powerful toolkit for building engaging web applications.

The complete source code showcases how thoughtful SVG structuring and animation orchestration can create compelling user experiences that would be difficult to achieve with other technologies.