Comments (5)
Cool, will try it out.
Thank you very much for the example 👍
from react-plx.
Hello @bogdansoare,
On the top of my head, you could just use widow.innerHeight
(or innerWidth
). So for example if you want for your effect to start on 120vh
and to finish on 200vh
you could pass options like this:
{
start: window.innerHeight * 1.2,
duration: window.innerHeight * 0.8,
properties: [
// ...
],
},
I think it is cleaner this way, as if I add support for vh
units, I would need add conditional check, then parse it, and at the end do the exact same thing with window.innerHeight
.
Hope it helps!
from react-plx.
Heelo @Stanko .
Thanks for the response. It's a good idea, the problem that I have with it is that I'm server rendering, and I don't have access to the window object.
Also I think there will be a problem when the window height changes.
from react-plx.
Plx
already handles window resize.
As for the server rendering, you should handle it by passing SERVER_RENDER
env variable, or just checking window type typeof window === 'undefined'
and render Plx
only in that case.
Naive example:
{ typeof window !== 'undefined' && <Plx /> }
or:
const isServer = typeof window === 'undefined';
<Plx
parallaxData={ isServer ? null : realParallaxData }
/>
from react-plx.
@bogdansoare I'm going to close this one.
from react-plx.
Related Issues (20)
- Run independent animation after scroll reaches an element
- TypeScript types HOT 4
- Scrolling On IE Edge browser jumping and moving Plx divs HOT 1
- react-plx and superposed html elements HOT 1
- Showcase: <antoniocosentino.com> HOT 2
- I have a page with the same component - the scroll position is always related to the first child HOT 4
- Set `end:` as pixel-difference to `start` ? HOT 1
- Act only on Sub-Elements of the Parallax HOT 2
- Choppy animation
- use react-plx inside svg HOT 4
- Strange flipping on mobile-devices while scrolling HOT 6
- dropped fps HOT 3
- Smoother effect using values with more decimals HOT 2
- Animating scale creates choppy animation, most notably on safari, but apparent in all browsers. HOT 7
- Is there a way to sequence from previous values? HOT 5
- Set fixed position when element is centered? HOT 2
- onPlxStart/ onPlxEnd function not running in right moment? HOT 2
- Possibility to add html <tag> prop back in? HOT 6
- End the animation when the element leaves the viewport HOT 2
- Using Plx with multiple React components HOT 5
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-plx.