@@ -5,7 +5,7 @@ import { useMotionValue, animate, motion } from "motion/react"
5
5
import { useState , useEffect , Fragment } from "react"
6
6
import useMeasure from "react-use-measure"
7
7
8
- export interface MarqueeProps {
8
+ export interface MarqueeProps extends React . HTMLAttributes < HTMLElement > {
9
9
children : React . ReactNode
10
10
gap ?: number
11
11
speed ?: number
@@ -27,6 +27,7 @@ export function Marquee({
27
27
className,
28
28
drag = false ,
29
29
separator,
30
+ ...rest
30
31
} : MarqueeProps ) {
31
32
const [ currentSpeed , setCurrentSpeed ] = useState ( speed )
32
33
const [ ref , { width, height } ] = useMeasure ( )
@@ -93,7 +94,7 @@ export function Marquee({
93
94
setIsTransitioning ( true )
94
95
setCurrentSpeed ( speed )
95
96
} ,
96
- onPointerUp : ( ) => {
97
+ onPointerUp : ( _event : React . PointerEvent < HTMLElement > ) => {
97
98
if ( window . matchMedia ( "(hover: none)" ) . matches ) {
98
99
setIsTransitioning ( true )
99
100
setCurrentSpeed ( speed )
@@ -105,14 +106,13 @@ export function Marquee({
105
106
const dragProps = drag
106
107
? {
107
108
drag : direction === "horizontal" ? ( "x" as const ) : ( "y" as const ) ,
108
- onDragStart : ( ) => {
109
- document . documentElement . style . cursor = "grabbing"
109
+ onPointerDown : ( ) => {
110
110
document . documentElement . style . setProperty (
111
111
"--cursor-grabbing" ,
112
112
"grabbing" ,
113
113
)
114
114
} ,
115
- onDragEnd : ( ) => {
115
+ onPointerUp : ( _event : React . PointerEvent < HTMLElement > ) => {
116
116
document . documentElement . style . cursor = "initial"
117
117
document . documentElement . style . removeProperty ( "--cursor-grabbing" )
118
118
} ,
@@ -132,7 +132,7 @@ export function Marquee({
132
132
133
133
const multiples = 2
134
134
return (
135
- < div className = { clsx ( "overflow-hidden" , className ) } >
135
+ < div className = { clsx ( "overflow-hidden" , className ) } { ... rest } >
136
136
< motion . div
137
137
className = "flex w-max"
138
138
style = { {
@@ -146,6 +146,10 @@ export function Marquee({
146
146
ref = { ref }
147
147
{ ...dragProps }
148
148
{ ...hoverProps }
149
+ onPointerUp = { event => {
150
+ dragProps . onPointerUp ?.( event )
151
+ hoverProps . onPointerUp ?.( event )
152
+ } }
149
153
>
150
154
{ Array . from ( { length : 2 } ) . map ( ( _ , i ) => (
151
155
< Fragment key = { i } >
0 commit comments