Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause on hover support? #249

Open
tiwka19 opened this issue Mar 16, 2024 · 5 comments
Open

Pause on hover support? #249

tiwka19 opened this issue Mar 16, 2024 · 5 comments

Comments

@tiwka19
Copy link

tiwka19 commented Mar 16, 2024

No description provided.

@tjenkinson
Copy link
Owner

Hey you should be able to wrap the marque element in a <div />, add onMouseEnter/onMouseLeave event listeners to that and set the rate to 0 to pause.

@tiwka19
Copy link
Author

tiwka19 commented Mar 16, 2024

Hey you should be able to wrap the marque element in a <div />, add onMouseEnter/onMouseLeave event listeners to that and set the rate to 0 to pause.

Thanks!

@tjenkinson
Copy link
Owner

No problem let me know if there are any issues

@somethingxdev
Copy link

somethingxdev commented May 2, 2024

No problem let me know if there are any issues

Im get an error in console
Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render

Here is the code for my component


import { useState } from 'react'
import { Marquee } from 'dynamic-marquee-react'
const MarqueeBrands = (props) => {
	const [rate, setRate] = useState(30)
	return (
		<div onMouseEnter={() => setRate(0)} onMouseLeave={() => setRate(30)}>
			<Marquee startOnScreen={true} rate={rate}>
				<div className="flex items-center justify-between">{props.first}</div>
			</Marquee>
			{props.second && (
				<Marquee startOnScreen={true} rate={-rate}>
					<div className="mt-4 flex items-center justify-between">{props.second}</div>
				</Marquee>
			)}
		</div>
	)
}

export default MarqueeBrands

@tjenkinson
Copy link
Owner

Hmm that looks like it should be fine. Can you reproduce the error on https://stackblitz.com/ ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants