question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

header jumps out of the container when sticked

See original GitHub issue

Hi,

As shown below, the header jumps outside the main div when it’s sticked : sticy issue

Here is the code, any idea why this happens?

` export default class Colonne extends React.Component { render() {

      var rows = rowTags.map((indicator, index) => (
            <div key={index} style={{ width: 500, overflowY:'hidden'}}>
              <Sticky relative  topOffset={80}>
                {
                  ({ isSticky, wasSticky, style, distanceFromTop, distanceFromBottom, calculatedHeight }) => {
                    return (
                      <div style={{ ...style, overflow: 'auto', background: '#aaa'}}>
                        <h2>
                          <span className="pull-left"><center>{indicator.label}</center></span>
                        </h2>
                      </div>
                    )
                  }
                }
              </Sticky>

              <Paper className='box' zDepth={1}>
              <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquet ullamcorper neque in consequat. Sed vehicula dolor in ante rutrum volutpat.</p>
              </Paper>
              <Paper className='box' zDepth={1}>
              <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquet ullamcorper neque in consequat. Sed vehicula dolor in ante rutrum volutpat.</p>
              </Paper>
              <Paper className='box' zDepth={1}>
              <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquet ullamcorper neque in consequat. Sed vehicula dolor in ante rutrum volutpat.</p>
              </Paper>
            </div>
      ))

  return(
    <div style={{ width: 500, overflowY:'hidden'}}>
      <StickyContainer style={{ height: 500, overflowY: 'auto', background: '#ddd'}}>
      {rows}
      </StickyContainer>
    </div>
  )

} } `

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vcarlcommented, Feb 23, 2018

I’m not able to reproduce this with relative={true} on the Sticky element, could somebody provide a complete reproduction? Ideally a git repo I can git clone, npm install, npm start, but a code snippet I can copy-paste would be helpful too. @dgladkov maybe? I don’t want to merge your PR (#210) without reproducing the problem myself.

0reactions
yourmediafriendcommented, May 15, 2018

I think this may be to do with the container being in an element with css transform / translate applied. This changes the origin of the position: fixed coordinates to that element rather than the viewport. I am having a similar problem. Wrapping element css {transform: translate3d(54px, 0px, 0px); } placeholderClientRect => DomRect{bottom:54, height:54, left:54, right:1920, top:0, width:1866, x:54, y:0} StickyHeader jumps 54px right

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is the sticky header getting stuck? - Stack Overflow
I inspect your code and I think because you have two conflicting classes the .header class is position:sticky and the class .sticky is...
Read more >
Position: stuck; — and a way to fix it | by Dannie Vinther
We want the headings to stick while scrolling on the document window, and we want to be able to scroll horizontally within the...
Read more >
Stop Using Fixed Headers and Start Using Sticky Ones
A case for sticking with fixed header positioning involves headers that condense vertically when scrolling down the page, then expand again when ...
Read more >
Dealing with overflow and position: sticky; | CSS-Tricks
Creating page content that sticks to the viewport as you scroll, something like a jump-to-anchor menu or section headings, has never been easier ......
Read more >
Sticky scroll - keep containers headers visible when ... - GitHub
The parent syntax nodes should smoothly stack up or goes out of stack while scrolling. This should be tied with the current viewport...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found