GithubHelp home page GithubHelp logo

Comments (7)

SachaG avatar SachaG commented on June 15, 2024

Supporting this would be awesome! Any news on this feature?

from react-headroom.

WickyNilliams avatar WickyNilliams commented on June 15, 2024

You shouldn't need to do anything to support this use-case. IIRC product hunt are using the original headroom, and there is no special support for this. Providing you know the height of the top component of the header, all you need to do is negatively translateY by that amount.

See this fiddle: https://jsfiddle.net/z74ujuoy/

from react-headroom.

KyleAMathews avatar KyleAMathews commented on June 15, 2024

Yeah this has been supported for a while. Just use the pinStart prop see http://kyleamathews.github.io/react-headroom/

from react-headroom.

SachaG avatar SachaG commented on June 15, 2024

Thanks, I'll try with the custom CSS example. But I don't really see how pinStart would help with this? If I understand correctly it changes when the element gets pinned and unpinned, but it doesn't change how much it gets translated by?

from react-headroom.

KyleAMathews avatar KyleAMathews commented on June 15, 2024

You just want the subheader to be pinned to the top correct? pinStart makes it so the subheader is only pinned once its at the top. Otherwise as soon as you scroll down it'd be snnaped to the top.

from react-headroom.

kici8 avatar kici8 commented on June 15, 2024

Please, can you give us an example?

from react-headroom.

hpohlmeyer avatar hpohlmeyer commented on June 15, 2024

I think this is not fixed. You can come close to the desired effect, but not fully.

Here is an example:
https://codesandbox.io/s/headroom-double-header-example-i4nc6?file=/src/App.js

If I do not set pinStart, the .headroom-unpinned class does not get applied before I scrolled past the whole header, including the subheader. After I have done that, it pops back in:

1

To avoid that, pinStart can be set to the negative height of the subheader. This is almost the desired outcome, but since pinStart is negative now, .headroom--unfixed won’t be applied anymore, which means the header stays fixed until we hit the header height an disappears immediately. In the meantime content will be hidden under the header.

2

Currently I do not see a way to work around it, without altering headroom. I currently see several ways to resolve this:

  1. Update shouldWork to handle negative pinStart values
  2. Let the user provide a custom header height, that overrides the calculated one
  3. Add a new property, that can be used to subtract a component from the wrapped content

I can provide a PR if you’d like @KyleAMathews. Maybe you can point me to your prefered solution …

from react-headroom.

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.