Inside the bounds, the element moves 1:1 with the drag; past the boundary, multiply the excess by a damping factor (usually 0.3–0.4) so it moves less than the actual drag distance — that's what creates the "resistance" that grows the further you pull.
On release (`pointerup`), switch `transition` to an overshoot easing (a "back"-style curve like `cubic-bezier(.34,1.56,.64,1)`) so it doesn't stop dead at the boundary — it overshoots slightly, then settles. That overshoot is the whole reason it's called "rubber band."
The switch matters: `transition: none` while dragging keeps it instantly responsive, and the transition only turns on at release — leave it on throughout the drag and a lag creeps in between the finger and the element, which feels stiff instead of elastic.
When to use
Use it at scroll boundaries, slider ends, the limits of a draggable card — anywhere you want to physically communicate "this is the edge."