Comments (7)
Supporting this would be awesome! Any news on this feature?
from react-headroom.
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.
Yeah this has been supported for a while. Just use the pinStart
prop see http://kyleamathews.github.io/react-headroom/
from react-headroom.
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.
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.
Please, can you give us an example?
from react-headroom.
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:
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.
Currently I do not see a way to work around it, without altering headroom
. I currently see several ways to resolve this:
- Update
shouldWork
to handle negativepinStart
values - Let the user provide a custom header height, that overrides the calculated one
- 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)
- Parent prop and ComponentWIllUnmount HOT 2
- Please add a Changelog.md or similar HOT 4
- not working HOT 1
- upTolerance not working HOT 4
- Possible reopen header when the mouse pointer covers the old header area. HOT 1
- Changing content of headroom
- Show hidden header on 'focus-within' HOT 1
- Override style
- × TypeError: Object.assign requires that input parameter not be null or undefined HOT 1
- Gatsby page jumps to top when scrolling down (caused by react-headroom)
- Financing
- Glitch in safari mobile HOT 9
- Safari scroll bouncing causes white space to appear HOT 18
- Surport umd module in CDN
- Manual 'reset' HOT 1
- How to change z-index HOT 1
- "onUnfix" is not a correct name.
- Error: You may need an appropriate loader to handle this file type... HOT 1
- Super expression must either be null or a function, not undefined HOT 2
- Headroom not working with Chakra UI
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-headroom.