Game of the Day
Orbit Drift
Thread a comet through gravity wells.
Drag down, or press ×.
Bounce when a drag supplied force; no bounce when a button did.
Emil Kowalski@emilkowalskiMade this with Motion's layout prop. Notice how when I drag it to dismiss there's a slight bounce at the end, but when I simply press the close button, there's no bounce at all. A drag requires some force, so adding a subtle bounce makes this transition feel more natural.
Emil Kowalski@emilkowalskiswapped spring animaton for an ease-out one so it feels less abrupt.
From emil-design-eng, “Spring animations”.
Open a card, then drag it down, or press ×.
Drag down, or press ×.
Drag down, or press ×.
const easeOut = { duration: 0.3, ease: [0.23, 1, 0.32, 1] };
const bouncy = { type: "spring", visualDuration: 0.4, bounce: 0.25 };
const [closedBy, setClosedBy] = useState<"drag" | "button">("button");
<motion.div
layout
transition={closedBy === "drag" ? bouncy : easeOut}
drag="y"
dragSnapToOrigin
onDragEnd={(_, info) => {
if (info.offset.y > 70 || info.velocity.y > 350) {
setClosedBy("drag");
setOpen(false);
}
}}
>
<button aria-label="Close" onClick={() => { setClosedBy("button"); setOpen(false); }}>×</button>
</motion.div>
Press New issue and type right away.
spring, visualDuration 0.25s, bounce 0.30transform 250ms var(--ease-out).dialog {
opacity: 0;
transform: scale(0.96);
transition: opacity 200ms var(--ease-out), transform 250ms var(--ease-out);
}
.dialog[data-open] {
opacity: 1;
transform: scale(1);
}
A drag gives momentum, so overshoot confirms the throw. A click gives none.