04Rubber-band limit — a pull whose extension shrinks sharply once a maximum distance value is passed
As the pulled distance value nears a set maximum value, the extension value grows by a sharply smaller amount for the same input, and once released the distance value snaps back to its original position.
Best forA short-list refresh, an area preventing excessive pulling
LINEARMAX_DdisplayedOf

<main class="stage">
<div class="prrbo is-demo" id="prrbo">
<div class="prrbo__panel">
<div class="prrbo__track" id="prrboTrack">
<span class="prrbo__cap"></span>
<span class="prrbo__marker" id="prrboMarker"></span>
</div>
<div class="prrbo__phone" id="prrboPhone">
<div class="prrbo__list" id="prrboList">
<div class="prrbo__row"></div>
<div class="prrbo__row"></div>
</div>
</div>
</div>
<span class="prrbo__hint" id="prrboHint">Pull down</span>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// 계산 겹(지수 감쇠 displayedOf())은 JS 에 있다 — 여기는 정적 배치만.
@include stage($stage-orange);
.prrbo {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
gap: $sp-3;
}
.prrbo__panel {
display: flex;
align-items: flex-end;
gap: $sp-4;
padding: $sp-4;
border-radius: $r-card;
background: $stage-paper;
}
.prrbo__track {
position: relative;
width: 20px;
height: 92px;
border-radius: $r-xs;
background: $subject-cream;
}
.prrbo__cap {
position: absolute;
left: -4px;
right: -4px;
bottom: 77px;
height: 2px;
background: $subject-orange-deep;
}
.prrbo__marker {
position: absolute;
left: 2px;
right: 2px;
bottom: 2px;
height: 12px;
border-radius: $r-xs;
background: $subject-blue-deep;
}
.prrbo__phone {
position: relative;
width: 156px;
height: 108px;
overflow: hidden;
border-radius: $r-sm;
background: $subject-cream;
touch-action: none;
cursor: grab;
}
.prrbo__list {
position: relative;
display: flex;
flex-direction: column;
gap: $sp-2;
padding: $sp-3;
}
.prrbo__row {
height: 18px;
border-radius: $r-xs;
background: $stage-paper;
}
.prrbo__hint {
color: $subject-ink;
font-size: 12px;
text-align: center;
}
@media (max-width: 340px) {
.prrbo__panel { padding: $sp-3; gap: $sp-2; }
.prrbo__track { height: 72px; }
.prrbo__cap { bottom: 60px; }
.prrbo__phone { width: 128px; height: 88px; }
}
@media (prefers-reduced-motion: reduce) {
.prrbo__marker, .prrbo__list { transition: none !important; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ff4d1f;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.prrbo {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
gap: 12px;
}
.prrbo__panel {
display: flex;
align-items: flex-end;
gap: 16px;
padding: 16px;
border-radius: 16px;
background: #ffffff;
}
.prrbo__track {
position: relative;
width: 20px;
height: 92px;
border-radius: 4px;
background: #fff7e6;
}
.prrbo__cap {
position: absolute;
left: -4px;
right: -4px;
bottom: 77px;
height: 2px;
background: #c93000;
}
.prrbo__marker {
position: absolute;
left: 2px;
right: 2px;
bottom: 2px;
height: 12px;
border-radius: 4px;
background: #0a4fe8;
}
.prrbo__phone {
position: relative;
width: 156px;
height: 108px;
overflow: hidden;
border-radius: 8px;
background: #fff7e6;
touch-action: none;
cursor: grab;
}
.prrbo__list {
position: relative;
display: flex;
flex-direction: column;
gap: 8px;
padding: 12px;
}
.prrbo__row {
height: 18px;
border-radius: 4px;
background: #ffffff;
}
.prrbo__hint {
color: #17141a;
font-size: 12px;
text-align: center;
}
@media (max-width: 340px) {
.prrbo__panel {
padding: 12px;
gap: 8px;
}
.prrbo__track {
height: 72px;
}
.prrbo__cap {
bottom: 60px;
}
.prrbo__phone {
width: 128px;
height: 88px;
}
}
@media (prefers-reduced-motion: reduce) {
.prrbo__marker, .prrbo__list {
transition: none !important;
}
}(function () {
var phone = document.getElementById('prrboPhone');
var marker = document.getElementById('prrboMarker');
var list = document.getElementById('prrboList');
var hint = document.getElementById('prrboHint');
var root = document.getElementById('prrbo');
// 계산 겹: LINEAR(70px) 까지는 raw 에 0.9 배로 거의 그대로 따라가다가, 그 뒤로는 MAX_D(120px) 에
// 점근하는 지수 감쇠(1-e^-x/K)로 늘어나는 폭이 급격히 줄어든다 — 같은 힘이라도 한계 근처에선 거의 안 늘어난다.
var LINEAR = 70, MAX_D = 120, K = 42, RAW_MAX = 260;
var TRACK_H = 92, SCALE = TRACK_H / 150;
function displayedOf(raw) {
if (raw <= LINEAR) { return raw * 0.9; }
var base = LINEAR * 0.9;
var excess = raw - LINEAR;
return base + (MAX_D - base) * (1 - Math.exp(-excess / K));
}
function apply(raw) {
var displayed = displayedOf(raw);
marker.style.transform = 'translateY(' + (-(displayed * SCALE)).toFixed(1) + 'px)';
list.style.transform = 'translateY(' + (displayed * 0.55).toFixed(1) + 'px)';
var pctOfCap = Math.round((displayed / MAX_D) * 100);
hint.textContent = raw > 4 ? ('Displaced ' + Math.round(displayed) + 'px · of limit ' + pctOfCap + '%') : 'Pull down';
}
var raw = 0, target = 0, raf = null;
function settle() {
raw += (target - raw) * 0.3;
if (Math.abs(target - raw) < 0.3) { raw = target; }
apply(raw);
if (raw !== target) { raf = requestAnimationFrame(settle); } else { raf = null; }
}
function goTo(v) { target = v; if (raf === null) { raf = requestAnimationFrame(settle); } }
var dragging = false, startY = 0, startRaw = 0;
function onDown(y) { dragging = true; startY = y; startRaw = raw; if (raf) { cancelAnimationFrame(raf); raf = null; } }
function onMove(y) {
if (!dragging) { return; }
raw = Math.max(0, Math.min(RAW_MAX, startRaw + (y - startY)));
apply(raw);
}
function onUp() { if (!dragging) { return; } dragging = false; goTo(0); }
function wireReal() {
phone.addEventListener('pointerdown', function (e) { root.classList.remove('is-demo'); stopAutoplay(); onDown(e.clientY); });
window.addEventListener('pointermove', function (e) { onMove(e.clientY); });
window.addEventListener('pointerup', onUp);
}
phone.style.touchAction = 'none';
wireReal();
apply(0);
// 자동 루프: raw 를 RAW_MAX 까지 크게 밀어 넣어 한계선에 점근만 하고 못 넘는 모습을 보인다.
var autoRaw = 0, autoTimer = null, autoDir = 1;
function autoTick() {
autoRaw += autoDir * 55;
if (autoRaw >= RAW_MAX) { autoRaw = RAW_MAX; autoDir = -1; goTo(0); return; }
if (autoRaw <= 0 && autoDir < 0) { autoRaw = 0; autoDir = 1; }
if (autoDir > 0) { raw = autoRaw; apply(raw); }
}
var reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
function stopAutoplay() { if (autoTimer) { clearInterval(autoTimer); autoTimer = null; } }
if (!reduce) { autoTimer = setInterval(autoTick, 170); }
})();import { useEffect, useRef } from "react";
import styles from "./PullRefreshRubberBandOverscroll.module.scss";
export type PullRefreshRubberBandOverscrollProps = {
color?: string;
};
export default function PullRefreshRubberBandOverscroll({
color = "#0a4fe8",
}: PullRefreshRubberBandOverscrollProps) {
const rootRef = useRef<HTMLDivElement | null>(null);
useEffect(() => {
const root = rootRef.current;
if (!root) return;
const phone = root.querySelector<HTMLDivElement>(`.${styles.phone}`);
const marker = root.querySelector<HTMLSpanElement>(`.${styles.marker}`);
const list = root.querySelector<HTMLDivElement>(`.${styles.list}`);
const hint = root.querySelector<HTMLSpanElement>(`.${styles.hint}`);
if (!phone || !marker || !list || !hint) return;
// 계산 겹: LINEAR(70px) 까지는 raw 에 0.9 배로 거의 그대로 따라가다가, 그 뒤로는 MAX_D(120px) 에
// 점근하는 지수 감쇠(1-e^-x/K)로 늘어나는 폭이 급격히 줄어든다 — 같은 힘이라도 한계 근처에선 거의 안 늘어난다.
const LINEAR = 70, MAX_D = 120, K = 42, RAW_MAX = 260;
const TRACK_H = 92, SCALE = TRACK_H / 150;
function displayedOf(raw: number) {
if (raw <= LINEAR) return raw * 0.9;
const base = LINEAR * 0.9;
const excess = raw - LINEAR;
return base + (MAX_D - base) * (1 - Math.exp(-excess / K));
}
function apply(raw: number) {
const displayed = displayedOf(raw);
marker!.style.transform = "translateY(" + (-(displayed * SCALE)).toFixed(1) + "px)";
list!.style.transform = "translateY(" + (displayed * 0.55).toFixed(1) + "px)";
const pctOfCap = Math.round((displayed / MAX_D) * 100);
hint!.textContent = raw > 4 ? ("밀림 " + Math.round(displayed) + "px · 한계의 " + pctOfCap + "%") : "아래로 당기세요";
}
let raw = 0, target = 0, raf: number | null = null;
function settle() {
raw += (target - raw) * 0.3;
if (Math.abs(target - raw) < 0.3) raw = target;
apply(raw);
raf = raw !== target ? requestAnimationFrame(settle) : null;
}
function goTo(v: number) { target = v; if (raf === null) { raf = requestAnimationFrame(settle); } }
let dragging = false, startY = 0, startRaw = 0;
function onDown(y: number) {
dragging = true; startY = y; startRaw = raw;
if (raf !== null) { cancelAnimationFrame(raf); raf = null; }
}
function onMove(y: number) {
if (!dragging) return;
raw = Math.max(0, Math.min(RAW_MAX, startRaw + (y - startY)));
apply(raw);
}
function onUp() { if (!dragging) return; dragging = false; goTo(0); }
function onPointerDown(e: PointerEvent) { stopAutoplay(); onDown(e.clientY); }
function onPointerMove(e: PointerEvent) { onMove(e.clientY); }
phone.style.touchAction = "none";
phone.addEventListener("pointerdown", onPointerDown);
window.addEventListener("pointermove", onPointerMove);
window.addEventListener("pointerup", onUp);
apply(0);
// 자동 루프: raw 를 RAW_MAX 까지 크게 밀어 넣어 한계선에 점근만 하고 못 넘는 모습을 보인다.
let autoRaw = 0, autoTimer: number | null = null, autoDir = 1;
function autoTick() {
autoRaw += autoDir * 55;
if (autoRaw >= RAW_MAX) { autoRaw = RAW_MAX; autoDir = -1; goTo(0); return; }
if (autoRaw <= 0 && autoDir < 0) { autoRaw = 0; autoDir = 1; }
if (autoDir > 0) { raw = autoRaw; apply(raw); }
}
function stopAutoplay() { if (autoTimer !== null) { window.clearInterval(autoTimer); autoTimer = null; } }
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
if (!reduce) { autoTimer = window.setInterval(autoTick, 170); }
return () => {
stopAutoplay();
if (raf !== null) cancelAnimationFrame(raf);
phone.removeEventListener("pointerdown", onPointerDown);
window.removeEventListener("pointermove", onPointerMove);
window.removeEventListener("pointerup", onUp);
};
}, []);
return (
<div ref={rootRef} className={styles.stage}>
<div className={styles.prrbo}>
<div className={styles.panel}>
<div className={styles.track}>
<span className={styles.cap} style={{ "--accent": color } as any} />
<span className={styles.marker} />
</div>
<div className={styles.phone}>
<div className={styles.list}>
<div className={styles.row} />
<div className={styles.row} />
</div>
</div>
</div>
<span className={styles.hint}>아래로 당기세요</span>
</div>
</div>
);
}04 Rubber-band limit — a pull whose extension shrinks sharply once a maximum distance value is passed — Measured area 9.799% · moving frames 15/23Original by GODRICH · SCSS and React ship in the zip · Pull to Refresh CSS: 9 Loading Patterns
The post this demo lives in
Pull to Refresh CSS: 9 Loading PatternsOne dragged distance value produces a progressively smaller displacement, one rotation value turns in proportion to that See all demos in this post
If you like this effect - similar demos
Loaders06 End-of-list reveal — a message appearing once the remaining-item value reaches zeroInfinite Scroll Loading: 9 Essential UI Patterns
Loaders01 Parallel multi-file progress values — each file's progress value updates independently within a list while several downloads run at onceDownload Progress Bar: 9 Loading UI Patterns
Loaders05 Critical-threshold pulse toggle — once a value enters a set low range, the whole bar brightens and dims on a steady rhythmCSS Progress Bar: 9 Game-Style Fill Patterns