Skip to content

Commit 39df651

Browse files
committed
fix(website): keep hero terminal in viewport on mobile, stop page scroll jump
- Scroll only terminal body instead of scrollIntoView so page doesn't jump on new lines - Cap terminal height on mobile (65vh) so it stays on screen; users can scroll past Made-with: Cursor
1 parent 986e670 commit 39df651

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

website/src/css/custom.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,25 @@ button,
828828
min-height: 220px;
829829
}
830830

831+
.hero-terminal-body-scroll {
832+
max-height: 380px;
833+
overflow-y: auto;
834+
}
835+
836+
@media (max-width: 996px) {
837+
.hero-terminal {
838+
max-height: min(380px, 65vh);
839+
display: flex;
840+
flex-direction: column;
841+
}
842+
843+
.hero-terminal-body-scroll {
844+
max-height: min(380px, calc(65vh - 32px));
845+
overflow-y: auto;
846+
-webkit-overflow-scrolling: touch;
847+
}
848+
}
849+
831850
.term-line {
832851
display: flex;
833852
margin-bottom: 6px;

website/src/pages/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ function AnimatedTerminal() {
6262
return () => timeouts.forEach(clearTimeout);
6363
}, []);
6464

65-
const endRef = React.useRef(null);
65+
const bodyRef = React.useRef(null);
6666
useEffect(() => {
67-
endRef.current?.scrollIntoView({ behavior: 'smooth' });
67+
if (bodyRef.current) {
68+
bodyRef.current.scrollTop = bodyRef.current.scrollHeight;
69+
}
6870
}, [lines]);
6971

7072
return (
@@ -74,7 +76,7 @@ function AnimatedTerminal() {
7476
<div className="hero-terminal-dot yellow" />
7577
<div className="hero-terminal-dot green" />
7678
</div>
77-
<div className="hero-terminal-body" style={{ maxHeight: '380px', overflowY: 'auto' }}>
79+
<div ref={bodyRef} className="hero-terminal-body hero-terminal-body-scroll">
7880
{lines.map((line, i) => (
7981
<motion.div
8082
key={i}
@@ -107,7 +109,6 @@ function AnimatedTerminal() {
107109
<span className="term-text">_</span>
108110
</motion.div>
109111
)}
110-
<div ref={endRef} />
111112
</div>
112113
</div>
113114
);

0 commit comments

Comments
 (0)