concept

Discrete animation — CSS reference

Discrete animation switches values instead of blending them. With linear easing, flex-start changes to flex-end at halfway progress. Display has special switching rules.

Formal Syntax & Structure

css syntaxcss
transition: justify-content 1s linear allow-discrete;

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>discrete-animation</title><style>body{margin:0}#a{padding:8px;background:rgb(232,237,241);color:rgb(0,0,0);box-sizing:border-box}#a{width:100px;height:60px;opacity:0.2;background:#2855ac;color:white;padding:0;transition:opacity 1000ms linear}#a.active{opacity:1;width:200px}#a{display:flex;justify-content:flex-start;transition:justify-content 1000ms linear allow-discrete}#a.active{justify-content:flex-end}</style><body><button id="toggle" type="button">Toggle panel</button><div id="a">Panel</div><script>const a=document.querySelector("#a");const toggle=document.querySelector("#toggle");toggle.onclick=()=>a.classList.toggle("active");function start(){getComputedStyle(a).opacity;getComputedStyle(a).width;toggle.click();getComputedStyle(a).opacity;getComputedStyle(a).width;return a.getAnimations()}async function sample(t,p="opacity"){const anim=start().find(x=>x.transitionProperty===p);if(!anim)return null;anim.pause();await anim.ready;anim.currentTime=t;return getComputedStyle(a).getPropertyValue(p)}</script></body></html>
CSS Reference