gm0t / react-sticky-el

MIT License
251 stars 47 forks source link

topOffset props not applying #33

Closed PradeepJaiswar closed 5 years ago

PradeepJaiswar commented 6 years ago
<Sticky id="detailSticky" topOffset={50} >
  /*childrens*/
</Sticky>

Still, inline style always says top: 0px when getting sticks. It should be equal to topOffset provided

gm0t commented 6 years ago

Hi! topOffset prop has a bit differ purpose

Sticky state will be triggered when the top of the element is topOffset pixels from the top of the scrollElement. Positive numbers give the impression of a lazy sticky state, whereas negative numbers are more eager in their attachment (check .

if you want to add an offset when element becomes sticky you can use something like this: <Sticky id="detailSticky" topOffset={50} stickyStyle={{ transform: 'translateY(50px)' }}> /* children */ </Sticky>

KiranMohan commented 4 years ago

Following should also work

<Sticky id="detailSticky" topOffset={-50} stickyStyle={{ paddingBottom: 50 }}> /* children */ </Sticky>