Comments (7)
targetElement
could also be used to end an animation early, just depends how the target is positioned.
It would help to know the exact effect that you're trying to achieve, then I could show you how it might be done with this library, or advise to use something else instead.
from react-scroll-parallax.
Thank you for the quick answer :)
The green block should stop at the end of the purple
https://codesandbox.io/s/react-scroll-parallax-target-element-forked-wy97bc?file=/src/styles.css
from react-scroll-parallax.
Something like this?
https://codesandbox.io/s/react-scroll-parallax-target-element-stop-early-nev746?file=/src/App.tsx
from react-scroll-parallax.
It should start in the middle (my example) and end at the bottom of purple
from react-scroll-parallax.
This is a good example https://react-scroll-parallax-examples.vercel.app/
At the end, how would you stop the animation when the circles are aligned?
Or stopping the letters here https://react-scroll-parallax.netlify.app/
from react-scroll-parallax.
I'm just guessing here ;-)
Updated the CodeSandbox:
https://codesandbox.io/s/react-scroll-parallax-target-element-stop-early-nev746?file=/src/styles.css
They stop animating when the target is out of view and they are aligned because of their ending CSS position is aligned and no transform styles are used at the end of the effect translateY={[-200, 0]}
.
Beyond that it's up to you to provide the correct styling to make it fit your specific needs.
from react-scroll-parallax.
That works, thanks! :))
A better API for this would be startScroll
accepting self
and add two others: duration
and offset
// before translateY changes the original position
// I think `window.addEventListener('load', ...)` is required here
const start = window.pageYOffset + element.getBoundingClientRect().top
...
startScroll: (start - offset)
endScroll: (start - offset) + duration
from react-scroll-parallax.
Related Issues (20)
- Allow users to disable parallax from ParallaxProvider HOT 3
- Scroll can't work when the root parent element set `position=sticky`
- Request for Help with Scroll Containers HOT 4
- Issue trying to us horizontal axis on NextJS HOT 3
- Making parallax move to end and back HOT 2
- Can't get an <a> tag to be clickable inside a layer HOT 1
- with react-custom-scrollbars HOT 1
- It always run onEnter at the beginning. HOT 1
- Mac OS - Scrolling only updates once you stop scrolling HOT 2
- Add `disabled` prop to `ParallaxProvider` HOT 1
- Not working with CRA or Create Next App HOT 3
- Scrolling beyond a `scrollStart` or `scrollEnd` value does not update the affected property to final value HOT 1
- Styles not defined in documentation HOT 1
- Next Js 13.5 Effects are not being rendered HOT 16
- Update props of parallax element HOT 2
- Cannot read properties of undefined (reading 'destroy') on live reload HOT 14
- Parallax effect not working in nextjs 13 HOT 6
- onLoad function does not fire on image layers HOT 1
- Could not find `react-scroll-parallax` context value. Please ensure the component is wrapped in a <ParallaxProvider> HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-scroll-parallax.