-
-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathTouchArea.tsx
More file actions
53 lines (48 loc) · 1.35 KB
/
TouchArea.tsx
File metadata and controls
53 lines (48 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import type React from "react"
interface TouchAreaProps {
scrollMode: boolean
isTracking: boolean
handlers: {
onTouchStart: (e: React.TouchEvent) => void
onTouchMove: (e: React.TouchEvent) => void
onTouchEnd: (e: React.TouchEvent) => void
onTouchCancel: (e: React.TouchEvent) => void
}
}
export const TouchArea: React.FC<TouchAreaProps> = ({
scrollMode,
isTracking,
handlers,
}) => {
const handleStart = (e: React.TouchEvent) => {
handlers.onTouchStart(e)
}
const handlePreventFocus = (e: React.MouseEvent) => {
e.preventDefault()
}
return (
// biome-ignore lint/a11y/useSemanticElements: layout container intentionally not a button
<div
role="button"
tabIndex={0}
className="flex-1 bg-neutral-800 relative touch-none select-none flex items-center justify-center p-4"
onTouchStart={handleStart}
onTouchMove={handlers.onTouchMove}
onTouchEnd={handlers.onTouchEnd}
onTouchCancel={handlers.onTouchCancel}
onMouseDown={handlePreventFocus}
>
<div className="text-neutral-600 text-center pointer-events-none">
<div className="text-4xl mb-2 opacity-20">
{scrollMode ? "Scroll Mode" : "Touch Area"}
</div>
{isTracking && <div className="loading loading-ring loading-lg" />}
</div>
{scrollMode && (
<div className="absolute top-4 right-4 badge badge-info">
SCROLL Active
</div>
)}
</div>
)
}