[ST_DRKRM] Experimental dev research By Studio This — Leeds, UK
LDS --:--:--
← Index
STDR_005Developing

Micro Tween

A tween engine with zero dependencies — no GSAP, no build step, one requestAnimationFrame loop. Where STDR_001 reaches for a library because momentum physics earns it, this is the other end of the spectrum: when all motion needs is one value moved over time through an ease, this is all there is to it. An ease, a duration, an update callback — nothing more. First written as the masked-line intro on jameszamyslianskyj.com, extracted here as a reusable engine.

Live demoSTDR_005

Specification

ID
STDR_005
Status
Developing — API may change until v1.0.0
Stack
Vanilla JS · requestAnimationFrame · React hook
Dependencies
None
Licence
MIT

Quick start

<link rel="stylesheet" href="stdr-tween.css"> <!-- optional mask helpers -->

<div class="stdr-mask"><span class="stdr-mask-line">Micro Tween</span></div>
<div class="stdr-mask"><span class="stdr-mask-line">An ease, a duration</span></div>

<script src="stdr-tween.js"></script>
<script>
  STDRTween.stagger(document.querySelectorAll('.stdr-mask-line'), {
    duration: 900,          // ms
    each: 120,              // stagger offset per item (ms)
    ease: 'easeOutQuint',   // or any t => t function
    update: (p, line) => { line.style.transform = `translateY(${(1 - p) * 110}%)`; },
  });
</script>

Notes

Canonical version is vanilla JS; the React hook mirrors its behaviour and cancels anything still running on unmount. The engine never touches the DOM — the update callback owns all writes, so it can drive transforms, opacity, counters or canvas alike. The clock starts on the first delivered frame, so a tween begun in a hidden tab waits and plays when the page is first seen. Reduced-motion is the caller's decision, with a helper provided. Full API in the repo README.