-
Notifications
You must be signed in to change notification settings - Fork 158
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
How do you stop the effect when the element is in the middle of the view #133
Comments
Happy to help but I'll need more info. Not sure what you're trying to achieve based on the description. |
Mi code is the next (forgot the perspective). Thanks!!! :D import Image from 'next/image';
import { useParallax, Parallax } from 'react-scroll-parallax';
import {
ParagraphMaxWidth,
Section,
Title,
LandingMinted,
FlexColContainer,
ImgMinted,
} from './styles';
export default function Landing4() {
const { ref } = useParallax({
speed: 100,
translateY: [0, 290, 'easeInOut'],
translateX: [0, -3, 'easeInOut'],
rotateY: [0, 0],
scale: [1.2, 0.85, 'easeOutBack'],
});
return (
<Section>
<LandingMinted>
<FlexColContainer>
<Title>
Minted to the <br /> metaverse
</Title>
<ParagraphMaxWidth>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Nobis,
eaque! Omnis accusantium, sapiente dolore sit obcaecati impedit
ratione officia quo voluptatem asperiores delectus eaque magnam quae
consequatur vero vitae mollitia. Lorem ipsum, dolor sit amet
consectetur adipisicing elit.
</ParagraphMaxWidth>
</FlexColContainer>
<ImgMinted>
<Parallax>
<div
ref={ref as React.RefObject<HTMLDivElement>}
className="lg:perspective-5
">
<div
className="lg:rotate-x-20
lg:rotate-y-30
lg:-rotate-z-6
translate-z-16">
<Image src="/nft-2.jpeg" width={350} height={350} />
</div>
</div>
</Parallax>
</ImgMinted>
</LandingMinted>
</Section>
);
} Screen.Recording.2022-02-09.at.10.50.44.1.mov |
Hi! I think I'm also facing the same issue, what I'm trying to do, is end the animation faster, so that for example where it would be at 50% progress it stops the effect. I thought that using endScroll would help with this, I tried using |
Ok few things:
There is currently no other way to stop an effect mid viewport aside from the points 2 and 3 above. |
@jscottsmith Thanks ! going to try that |
Comment here if you still need help. See #134 |
Thanks!!!! I will try too :D |
thank you! I got it, export default function Landing5() {
const animationMd = useParallax({
startScroll: 3200,
endScroll: 4300,
translateY: [-100, 0, 'easeInOut'],
scale: [0, 1, 'easeInOut'],
opacity: [0, 1, 'easeInOut'],
}).ref;
return (
<Parallax>
<div
ref={animationMd as React.RefObject<HTMLDivElement>}
className="hidden md:block lg:hidden">
<NftCard showText />
</div>
</Parallax>
)
} |
Is there any way to use these values as relative? |
I found a good solution for me that is responsive. You will need to create a targetElement as helper. An example how you can define a targetElement can be found here. This is my code for the refs:
then I used the targetElement on an absolute
Now you can change the value of I am using Tailwind. ClassNames in css:
|
I need to stop scrolling when an image lands inside a card, but endScroll doesn't work for me. Any suggestion?
I don't know how to stop it.
Thanks!
The text was updated successfully, but these errors were encountered: