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.

Merge branch 'feat/see-inside-compare' into sic/04a

matin43ec8788c702
diff --cc animations/04-micro-interactions/magnetic-button/index.html
index 4fc7f276,a3f9df45..754b1702
--- a/animations/04-micro-interactions/magnetic-button/index.html
+++ b/animations/04-micro-interactions/magnetic-button/index.html
@@@ -31,49 -31,9 +31,49 @@@
/* The site focus ring is drawn inside the button. It has the same orange as the fill, so it turns dark. */
.hb-page .stage .mag:focus-visible{outline-color:#0b0b0d}
@media(prefers-reduced-motion:reduce){.mag,.mag .mag-label{transition:transform .12s linear}}
+ /* See inside and Compare, drawn over the stage from the page's own numbers: the ring the pull reaches, the button's resting
+ place, the lean (an arrow over a dark edge, so the button's words stay readable under it), a faint line to the pointer, a
+ pretend pointer, and in Compare a ghost of the pointer over the copy that stays put. */
+ .twin,.views,.lbl{display:none}
+ .views{position:absolute;inset:0;pointer-events:none}
+ .views svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
+ .ring,.rest,.lean-edge,.lean,.toward,.pointer,.ghost{display:none}
+ .ring{fill:rgba(255,157,92,.06);stroke:rgba(255,157,92,.75);stroke-width:2;stroke-dasharray:6 6}
+ .rest{fill:none;stroke:rgba(244,244,242,.6);stroke-width:2;stroke-dasharray:5 5}
+ .lean-edge{fill:none;stroke:#0b0b0d;stroke-width:6;stroke-linecap:round;stroke-linejoin:round}
+ .lean{fill:none;stroke:#f4f4f2;stroke-width:3;stroke-linecap:round;stroke-linejoin:round}
+ .toward{stroke:rgba(244,244,242,.45);stroke-width:1.5;stroke-dasharray:3 5}
+ .pointer path,.ghost path{fill:#f4f4f2;stroke:#0b0b0d;stroke-width:1.5;stroke-linejoin:round}
+ .ghost{opacity:.7}
+ .lbl{position:absolute;padding:3px 7px;border-radius:5px;background:rgba(11,11,13,.88);color:#f4f4f2;font:600 13px/1.2 var(--hb-font);white-space:nowrap}
+ .stage[data-hb-mode="inside"] .views,.stage[data-hb-mode="compare"] .views{display:block}
+ .stage[data-hb-mode="inside"] .ring,.stage[data-hb-mode="inside"] .rest,.stage[data-hb-mode="inside"] .lean-edge,
+ .stage[data-hb-mode="inside"] .lean,.stage[data-hb-mode="inside"] .toward,.stage[data-hb-mode="compare"] .toward{display:inline}
+ .stage[data-hb-mode="inside"].pretend .pointer,.stage[data-hb-mode="compare"].pretend .pointer,.stage[data-hb-mode="compare"] .ghost{display:inline}
+ .stage[data-hb-mode="inside"] .in-l,.stage[data-hb-mode="compare"] .cmp-l{display:block}
+ /* Compare: the copy that stays put in the middle of the first half (left, or top on phones), the real button in the second.
+ The real button keeps its place in the layout and the script moves it with translate: moved by layout and back, its words
+ came back drawn a fraction of a pixel off in Normal. */
+ .stage[data-hb-mode="compare"] .twin{display:inline-block;position:absolute;left:25%;top:50%;translate:-50% -50%;white-space:nowrap}
+ .cmp-l{top:12px;left:12px}
+ .cmp-l.second{left:calc(50% + 12px)}
+ /* In Compare the pointer and its line keep to the real button's half, and the ghost to the copy's */
+ .stage[data-hb-mode="compare"] .views svg{clip-path:inset(0 0 0 50%)}
+ .stage[data-hb-mode="compare"] .views .half-one{clip-path:inset(0 50% 0 0)}
+ @media(max-width:600px){
+ .stage[data-hb-mode="compare"] .twin{left:50%;top:25%}
+ .stage[data-hb-mode="compare"] .cmp-l.second{left:12px;top:calc(50% + 8px)}
+ .stage[data-hb-mode="compare"] .views svg{clip-path:inset(50% 0 0 0)}
+ .stage[data-hb-mode="compare"] .views .half-one{clip-path:inset(0 0 50% 0)}
+ }
+ /* Under reduced motion the views take their pose at once, with no glide */
+ @media(prefers-reduced-motion:reduce){
+ .stage[data-hb-mode="inside"] .mag,.stage[data-hb-mode="inside"] .mag .mag-label,
+ .stage[data-hb-mode="compare"] .mag,.stage[data-hb-mode="compare"] .mag .mag-label{transition:none}
+ }
</style>
- <link rel="stylesheet" href="../../../assets/css/demo-page.css?v=9">
- <script src="../../../assets/js/demo-page.js?v=9" defer></script>
+ <link rel="stylesheet" href="../../../assets/css/demo-page.css?v=10">
+ <script src="../../../assets/js/demo-page.js?v=10" defer></script>
</head>
<body class="hb" data-hb-kind="do" data-hb-autoplay>
<nav class="hb-bar" aria-label="Animation Handbook">