Giter VIP home page Giter VIP logo

Comments (5)

bogdansoare avatar bogdansoare commented on July 22, 2024 1

Cool, will try it out.
Thank you very much for the example 👍

from react-plx.

Stanko avatar Stanko commented on July 22, 2024

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.

bogdansoare avatar bogdansoare commented on July 22, 2024

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.

Stanko avatar Stanko commented on July 22, 2024

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.

Stanko avatar Stanko commented on July 22, 2024

@bogdansoare I'm going to close this one.

from react-plx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.