← Entrances

Suck In

The element winds back for a moment, then spins faster and faster as it’s sucked into a single point, like water down a drain. Move the point to a corner and it spirals in towards it.

Files compressedreport-2026.zip

How to use it

  1. Paste the snippet just before </head>.
  2. Add data-suck-in to any element.

Options

Add any of these attributes to the same element.

data-turnsHow many turns it makes. Negative spins anticlockwise. Default 2.
data-originThe point it’s sucked into, as a CSS transform-origin like right top. Default the centre.
data-durationHow long it takes to vanish, after the wind-up. Default 850 ms.
data-delayHow long it stays in view before it goes. Default 1200 ms.
data-loopFade back in, hold and get sucked in again.
data-holdHow long it stays between exits, when looping. Default 1400 ms.

It plays once it has been in view for data-delay, and ends hidden (visibility: hidden) but still taking up its space. To play it when you choose, such as when something is dismissed, leave the attribute off and call animacious.suckIn(el).

1 · Snippet
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/bundles/anime.umd.min.js"></script>
<script>
  (function () {
    // Suck In: the element winds back for a moment, then spins faster and
    // faster as it is sucked into a single point, like water down a drain.
    // Usage: <div data-suck-in>…</div>
    // It plays once the element has been in view for data-delay ms, and ends
    // hidden (visibility: hidden) but still taking up its space.
    // Optional: data-turns (how many turns, negative for anticlockwise,
    // default 2), data-origin (the point it is sucked into, as a CSS
    // transform-origin like "right top"; away from the centre it spirals in
    // towards it, default the centre), data-duration (ms, default 850),
    // data-delay (ms in view before it leaves, default 1200), data-loop (fade
    // back in, hold and get sucked in again), data-hold (ms to stay between
    // exits when looping, default 1400).
    // Script use: animacious.suckIn(el, done) plays it on any element now,
    // using its data-* options, and calls done afterwards.
    var DEFAULTS = { turns: 2, duration: 850, delay: 1200, hold: 1400 };

    function reduced() {
      return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
    }

    function leave(el, done) {
      var d = el.dataset;
      var t = +d.duration || DEFAULTS.duration;
      var turns = d.turns === undefined ? DEFAULTS.turns : +d.turns || 0;
      var sign = turns < 0 ? -1 : 1;
      if (reduced()) {
        anime.utils.set(el, { opacity: 0 });
        if (done) done();
        return;
      }
      if (d.origin) el.style.transformOrigin = d.origin;
      anime.utils.set(el, { rotate: 0, scale: 1, filter: 'blur(0px)' });
      anime.createTimeline({
        onComplete: function () {
          if (done) done();
        }
      })
        // Wind back and swell a touch, as if resisting the pull.
        .add(el, { rotate: -12 * sign, scale: 1.05, duration: 240, ease: 'out(2)' })
        .add(el, {
          rotate: { to: turns * 360, ease: 'in(3)' },
          scale: { to: 0, ease: 'in(2.5)' },
          filter: { to: 'blur(2px)', ease: 'in(3)' },
          opacity: { to: 0, delay: t * 0.75, duration: t * 0.25, ease: 'in(2)' },
          duration: t
        });
    }

    function cycle(el) {
      var d = el.dataset;
      var s = el._sck;
      leave(el, function () {
        if (d.loop === undefined || d.loop === 'false') {
          el.style.visibility = 'hidden';
          return;
        }
        // Come back quietly in place, then go again once it's on screen.
        setTimeout(function () {
          anime.utils.set(el, { rotate: 0, scale: 1, opacity: 0 });
          el.style.filter = '';
          anime.animate(el, {
            opacity: 1,
            duration: 400,
            ease: 'out(2)',
            onComplete: function () {
              setTimeout(function () {
                if (s.visible) cycle(el);
                else s.waiting = true;
              }, +d.hold || DEFAULTS.hold);
            }
          });
        }, 400);
      });
    }

    window.animacious = window.animacious || {};
    window.animacious.suckIn = function (el, done) {
      leave(el, function () {
        el.style.visibility = 'hidden';
        if (done) done(el);
      });
    };

    function init() {
      var io = new IntersectionObserver(function (entries) {
        entries.forEach(function (e) {
          var s = e.target._sck;
          s.visible = e.isIntersecting;
          if (!e.isIntersecting) return;
          if (!s.started) {
            s.started = true;
            var wait = e.target.dataset.delay;
            setTimeout(function () { cycle(e.target); }, wait === undefined ? DEFAULTS.delay : +wait || 0);
          } else if (s.waiting) {
            s.waiting = false;
            cycle(e.target);
          }
        });
      }, { threshold: 0.2 });
      document.querySelectorAll('[data-suck-in]').forEach(function (el) {
        if (el._sck) return;
        el._sck = {};
        if (!reduced()) io.observe(el);
      });
    }

    if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init);
    else init();
  })();
</script>
2 · Your HTML
<div class="card" data-suck-in>Files compressed</div>

<!-- or spiralling into its top right corner: -->
<div class="card" data-suck-in data-origin="right top">Files compressed</div>