Wiggle Loop

Makes a wiggle loop perfectly every few seconds—great for looping titles, GIFs, boomerangs, or repeatable motion in templates.

Author:
Denis Stefanides
Category:
Wiggle, Loop

Expression Code

// How fast the wiggle moves (per second)
wigglesPerSecond = 2;

// How much the property moves (in pixels, degrees, etc.)
wiggleAmount = 40;

// Loop length (in seconds)
loopTime = 3;

// Time within the loop (wraps around every 'loopTime' seconds)
current = time % loopTime;

// Sample two wiggles: one at current time, one a full loop earlier
start = wiggle(wigglesPerSecond, wiggleAmount, 1, 0.5, current);
end = wiggle(wigglesPerSecond, wiggleAmount, 1, 0.5, current - loopTime);

// Blend between the two wiggle states for a perfect loop
linear(current, 0, loopTime, start, end);
jsx

Where to Apply

Use this on Position, Rotation, Scale, or any animatable property where you’d normally use a wiggle.

Especially useful for:

  • Looping animated titles

  • GIFs or seamless exports

  • Templates that need repeatable motion


How It Works

Alright, here's the trick:

  • time % loopTime wraps the time back to 0 once it hits the loop length—this creates the loop cycle.

  • We sample two wiggle() calls:

    • One at the current loop time

    • One a full loop earlier

  • Then linear() blends between those two samples so the animation loops smoothly.

This method keeps the organic, random feel of wiggle(), but with a clean loop every loopTime seconds.

Frequently asked questions

How do I use the expression on this page?

Just copy the full expression code from the top of this page. Then Alt-click (or Option-click on Mac) the stopwatch on the property you want to animate. Paste the code into the editor and that's it. If you’re not sure which property to use, check the "Where to Apply" section above.

The expression isn’t working. What should I check?

First, make sure your project is using the JavaScript engine (go to File > Project Settings > Expressions). Also double-check for missing characters, and see if the code requires parenting a layer. If so, there will be a comment in the code explaining what needs to be connected.

I’m not sure what the expression does. Where can I learn more?

Take a look at the "How It Works" section on this page. It explains each part of the expression in plain language so you can understand how everything works together.

Can I customize how the expression behaves?

Yes, absolutely. Most expressions include easy-to-edit variables near the top and comments that guide you on what to change. You can also link sliders or checkboxes using Expression Controls if you want more control in the timeline.

Can I apply this to other properties too?

Yes, you can use it on any property with a stopwatch. That includes Position, Scale, Opacity, and also effect settings like Blur or Tint.

Will it work in comps with different frame rates or sizes?

In most cases, yes. These expressions are designed to adapt to your comp’s resolution and frame rate. If anything specific needs adjusting, it’ll be noted in the code or in the "How It Works" section.

Related Expressions

Explore more expressions in this category