Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

fix: Add-to-Cart Fly: under reduced motion Show me's press holds the pressed look without easing, and the README says so

matin8adb894f6e1a
diff --git a/animations/04-micro-interactions/add-to-cart-fly/README.md b/animations/04-micro-interactions/add-to-cart-fly/README.md
index ad1261b1..e852bd24 100644
--- a/animations/04-micro-interactions/add-to-cart-fly/README.md
+++ b/animations/04-micro-interactions/add-to-cart-fly/README.md
@@ -42,7 +42,7 @@ When the vertical animation's `finished` promise resolves, the copy is removed,
- **Update the cart at once**: add the item to the cart data right away and only delay the visible count, so nothing is lost if the visitor leaves mid-flight, and announce the change to screen readers through a live region.
- **Many presses**: each press gets its own copy; cancel copies still in the air (`animation.cancel()`) when the cart is emptied or the view changes.
- **Keep it short**: a flight much longer than a second makes a quick shopper wait for feedback, and on a page where people add dozens of items, a simple count change is kinder.
-- **Reduced motion**: under `prefers-reduced-motion: reduce` nothing flies and the cart does not bump; the new number fades in.
+- **Reduced motion**: under `prefers-reduced-motion: reduce` nothing flies and the cart does not bump; the new number fades in. The button's press is not eased either: a real press switches to the pressed look at once (no transition), and Show me's press only holds that look for a moment.
- **Libraries**: GSAP's MotionPathPlugin flies an element along a curve (`motionPath: { path: [...], curviness: 1.25 }`), Framer Motion can give `x` and `y` different `ease` values for the same arc, and the CSS `offset-path` property is another way to follow a curve.
## See also
diff --git a/animations/04-micro-interactions/add-to-cart-fly/index.html b/animations/04-micro-interactions/add-to-cart-fly/index.html
index 86b0ac95..0894fa35 100644
--- a/animations/04-micro-interactions/add-to-cart-fly/index.html
+++ b/animations/04-micro-interactions/add-to-cart-fly/index.html
@@ -257,7 +257,9 @@
toRest();
later(()=>{
const btn=prods[0].querySelector('.add');
- btn.animate([{transform:'none'},{transform:'scale(.95)',offset:.3},{transform:'none'}],{duration:300,easing:'ease-out'});
+ // Under reduced motion the pressed look is only held for a moment, with no easing in or out
+ btn.animate(reduce.matches?[{transform:'scale(.95)'},{transform:'scale(.95)'}]:[{transform:'none'},{transform:'scale(.95)',offset:.3},{transform:'none'}],
+ {duration:reduce.matches?150:300,easing:'ease-out'});
awaiting=true;
add(prods[0],true,()=>{if(!awaiting)return;awaiting=false;later(back,450,1200)});
},0,300);