Building Custom Sliders Using GSAP: When Swiper Doesn’t Work Well

A slider starts as a simple requirement: show some content, add navigation, and move between slides.

Then the design arrives.

The image needs to move independently from the text. The next slide should appear before the previous one has fully disappeared. Navigation needs to follow a specific sequence. Mobile needs a different treatment.

At that point, the challenge is no longer just moving slides. It is building an interaction around the design.

That was the approach I took on the Bertone website project. I built a custom WordPress theme based on the agency’s design. I used ACF for content editing, which made it easy to manage and update. For animations I relied heavily on GSAP. I created custom GSAP-driven sliders of using Swiper. This gave me control over the motion and timing. Every part of the site had animations that matched the brand’s style. I made sure everything worked fast and looked sharp on all devices. The result was a engaging site, with a unique feel that stood out.

This does not mean every carousel needs a custom implementation. It means the choice of tool should follow the interaction you need to build.

When a slider library is the choice

Swiper, Slick and other similar libraries solve a familiar problem: showing a set of items with the same navigation and movement.

For a product carousel a testimonial section or an image gallery a slider library can save a lot of development time.

Swiper for example offers modules, for navigation, pagination, keyboard controls, accessibility and several kinds of movement. These are features that you would have to build and test yourself. Swiper API documentation

If the design works with how the library acts using it makes sense.

The problem happens when the design asks for a way of interacting.

Where custom designs create friction

Developers who have worked on heavily customized sliders will probably recognize the moment when configuration turns into workarounds.

You start with a straightforward setup. Then you add event handlers, override styles, introduce special conditions at different breakpoints, and manage animations outside the slider.

Eventually, two systems may be trying to control the same experience:

  • The slider manages position, active state, and transition timing.
  • Your animation code manages the visual sequence around it.

Neither system is necessarily wrong. But keeping them synchronized can become difficult.

Common pressure points include independently animated content, overlapping slides, unusual navigation, and transitions that need to coordinate with elements outside the slider.

These are general examples, rather than a list of specific Bertone implementation details. The underlying question is the same:

How much of the library’s behavior are you still using, and how much are you working around?

A custom interaction is not automatically impossible with a conventional slider. But sometimes implementing it cleanly requires more effort than building the behavior directly.

The approach I used for Bertone

For Bertone, the sliders were custom GSAP-driven components rather than Swiper instances.

My role was to translate the supplied design into a working custom WordPress theme, provide editable content through ACF, and implement the frontend interactions.

Building the sliders directly gave me control over their animation sequences without having to fit those sequences around another slider’s transition lifecycle.

It also kept the implementation aligned with the wider animation work on the site.

The important distinction is that GSAP provides the animation layer. It does not automatically provide the complete slider component.

Slide state, navigation, interaction rules, and accessibility still need to be designed and implemented.

Separate slide state from animation

A useful way to structure a custom slider is to separate three responsibilities.

State tracks the active slide, the destination slide, and whether a transition is running.

Controls translate user actions into requests to change slides.

Animation handles how the outgoing and incoming content move.

This separation makes changes easier to reason about. Adjusting the transition should not require rewriting navigation. Adding another navigation control should not require duplicating animation code.

For the animation itself, a GSAP timeline lets you coordinate several tweens and control when they overlap. That is useful when images, headings, and supporting content need different timings within one transition. GSAP timeline documentation

A simplified GSAP transition

The following example demonstrates the transition layer. It is a teaching example, not the actual Bertone source code or a complete production slider.

Assume slides contains the slide elements, each with an image and a heading. The slides occupy the same area, with only the active slide visible initially.

let activeIndex = 0;
let isAnimating = false;

const reducedMotion = window.matchMedia(
  "(prefers-reduced-motion: reduce)"
);

function goToSlide(nextIndex, direction = 1) {
  if (
    isAnimating ||
    nextIndex === activeIndex ||
    nextIndex < 0 ||
    nextIndex >= slides.length
  ) {
    return;
  }

  const current = slides[activeIndex];
  const next = slides[nextIndex];
  const nextImage = next.querySelector(".slide__image");
  const nextTitle = next.querySelector(".slide__title");

  isAnimating = true;

  // Controls live outside the slides. If focus is inside the
  // outgoing slide, move it to a stable control before hiding it.
  if (current.contains(document.activeElement)) {
    nextButton.focus();
  }

  current.inert = true;
  current.setAttribute("aria-hidden", "true");

  // Reveal the incoming slide visually, but keep it inactive
  // until the transition has finished.
  next.hidden = false;
  next.inert = true;
  next.setAttribute("aria-hidden", "true");

  function finish() {
    current.hidden = true;
    next.inert = false;
    next.removeAttribute("aria-hidden");

    activeIndex = nextIndex;
    isAnimating = false;

    status.textContent = `Slide ${activeIndex + 1} of ${slides.length}`;
  }

  if (reducedMotion.matches) {
    gsap.set(next, { opacity: 1 });
    gsap.set([nextImage, nextTitle], { xPercent: 0, y: 0, opacity: 1 });
    finish();
    return;
  }

  gsap.timeline({
    defaults: { ease: "power2.out" },
    onComplete: finish
  })
    .to(current, { opacity: 0, duration: 0.3 }, 0)
    .fromTo(next,
      { opacity: 0 },
      { opacity: 1, duration: 0.45 }, 0.1)
    .fromTo(nextImage,
      { xPercent: direction * 8 },
      { xPercent: 0, duration: 0.65 }, 0.1)
    .fromTo(nextTitle,
      { y: 24, opacity: 0 },
      { y: 0, opacity: 1, duration: 0.4 }, 0.25);
}

Here, nextButton is a native button outside the slides, and status is a separate element with aria-live="polite". Inactive slides should start with hidden, inert, and aria-hidden="true".

The example makes one deliberate interaction choice: it ignores additional navigation requests while an animation is running.

That is simple and predictable, but it is not the only option. A different interface might queue the latest request or allow an animation to be interrupted. What matters is choosing a policy rather than letting competing transitions decide the result.

The reduced-motion branch skips the animated transition. For larger responsive animation setups, GSAP also provides gsap.matchMedia() to organize behavior around media queries and motion preferences. GSAP matchMedia documentation

The animation is part of the work.

A polished transition can make a component look finished before it actually is.

Before shipping a custom slider there are questions to answer.

Can someone operate the custom slider with a keyboard? Do hidden slides contain links that remain focusable? Is the slide communicated clearly? What happens when someone navigates repeatedly?

Responsive behavior needs attention. Text length, image proportions and available space can change dramatically between desktop and mobile.

If the design requires dragging or swiping those interactions need their implementation and testing. Touch gestures also need to coexist with normal page scrolling.

The code above does not implement dragging, autoplay, dynamic slide insertion or teardown. A production component also needs a way to remove event listeners and stop its animations when it is removed or rebuilt.

These responsibilities are part of the cost of choosing a custom slider.

Custom does not automatically mean faster

Replacing a slider library with GSAP does not prove a performance improvement.

If GSAP is already used throughout a site a small custom slider may avoid adding another dependency.. The result still depends on the implementation.

Large images, visual effects, unnecessary layout calculations and excessive animation can make a custom slider slow too.

Performance claims should come from measurement. For Bertone the reason to discuss this approach is control over the interaction—not a claim that custom sliders are always lighter or faster.

How I decide which approach to use

I would usually go with a slider library when the design follows carousel behavior and requires standard features like touch navigation, pagination or multiple slides visible at once.

If the transition is a core part of the design and multiple elements need to move in sync I’d lean toward a custom GSAP solution. Using a library in those cases might add complexity.

There’s also a ground: use a slider library for handling navigation and swipe gestures then use GSAP for animations around the content. That often works well when each tool has a role.

The key is picking the method that’s easiest to build understand and keep up with for the project at hand.

For the Bertone project I chose a custom GSAP-driven slider to make the design work, on the web as intended.

When the interaction goes beyond sliding-like when the carousel is just one part of a bigger experience—it’s worth stepping back and asking if a general slider is still the best fit.

View the Bertone project