-
Notifications
You must be signed in to change notification settings - Fork 12
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
Plugin don't work at all. #6
Comments
Hi @rzubrycki, can you explain us more about your problem?. |
No, i don't use it.
After start of an app, i see ease-in animation on header and then nothing happen on scroll. |
Hi! We can't see the plugin in the dependencies. Can you show your |
@rzubrycki You might have better luck with a different solution. There's nothing Gatsby-specific about this behavior, and the dependency doing the heavy lifting uses a very non-React approach. import { useInView } from "react-intersection-observer"
const AnimateIn = ({ threshold = 0.15, triggerOnce = false, ...remainingProps }) => {
const [ref, inView] = useInView({ threshold, triggerOnce })
return (
<div
ref={ref}
style={{
// adjust these as desired
transition: "opacity 300ms, transform 300ms",
opacity: inView ? 1 : 0,
transform: `translateY(${inView ? 0 : 100}px)`,
}}
{...remainingProps}
/>
)
} Then just wrap any components you want entrance animations on with this component, overriding the default <AnimateIn triggerOnce={true}>
<h1>Hi Mom!</h1>
</AnimateIn> This is much easier to reason about, doesn't couple itself to Gatsby, and you can easily extend or modify it to do anything else you need, all without adding a bunch of additional dependencies to your client-side code. You can even use this approach to auto-play videos when they're in view and pause them when they're not: import { useInView } from "react-intersection-observer"
const AutoPlayingVideo = ({ threshold = 0.15, ...playerProps }) => {
const [ref, inView] = useInView({ threshold })
useEffect(() => {
if (inView) {
ref.current?.play()
} else {
ref.current?.pause()
}
}, [ref, inView])
return (
<video
style={{
transition: "opacity 300ms, transform 300ms",
opacity: inView ? 1 : 0,
transform: `translateY(${inView ? 0 : 100}px)`,
}}
ref={ref}
autoPlay
playsInline
muted
loop
{...playerProps}
/>
)
} |
@coreyward Thank you so much. I experienced strange problems with the plugin - your approach works much better. |
@Trunksome Fixed! |
Hi, i followed your example, but nothing happens when scrolling.
The text was updated successfully, but these errors were encountered: