Skip to content

Commit 7b1dd09

Browse files
committed
add touch support to Link component
1 parent affed48 commit 7b1dd09

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

src/components/hero-404/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,18 @@ void main() {
205205

206206
function onTouchStart(e: TouchEvent) {
207207
isDragging = true;
208-
e.preventDefault();
208+
if (e.target instanceof HTMLCanvasElement) {
209+
e.preventDefault();
210+
}
209211
}
210212

211213
function onTouchMove(e: TouchEvent) {
212214
if (!isDragging) return;
213215

214216
// Prevent default touch behavior
215-
e.preventDefault();
217+
if (e.target instanceof HTMLCanvasElement) {
218+
e.preventDefault();
219+
}
216220

217221
const touchX = e.touches[0].clientX;
218222
const touchY = e.touches[0].clientY;

src/components/hero/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,18 @@ void main() {
207207

208208
function onTouchStart(e: TouchEvent) {
209209
isDragging = true;
210-
e.preventDefault();
210+
if (e.target instanceof HTMLCanvasElement) {
211+
e.preventDefault();
212+
}
211213
}
212214

213215
function onTouchMove(e: TouchEvent) {
214216
if (!isDragging) return;
215217

216218
// Prevent default touch behavior
217-
e.preventDefault();
219+
if (e.target instanceof HTMLCanvasElement) {
220+
e.preventDefault();
221+
}
218222

219223
const touchX = e.touches[0].clientX;
220224
const touchY = e.touches[0].clientY;

src/components/link/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ export const Link = ({ href, children, ...props }: LinkProps) => {
1919
});
2020

2121
return (
22-
<NextLink href={href} ref={ref} onMouseOver={replay} {...props}>
22+
<NextLink
23+
href={href}
24+
ref={ref}
25+
onMouseOver={replay}
26+
onTouchStart={replay}
27+
{...props}
28+
>
2329
{children}
2430
</NextLink>
2531
);

0 commit comments

Comments
 (0)