Skip to content

Is there a way to bottom out the sticky element at n pixels? #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
benlwilliams opened this issue Apr 26, 2016 · 9 comments
Open

Is there a way to bottom out the sticky element at n pixels? #173

benlwilliams opened this issue Apr 26, 2016 · 9 comments

Comments

@benlwilliams
Copy link

I have need for a offset_bottom type of option. Does one exist or is there some way to accomplish this without having to rewrite the plugin?

For example, I need the bottoming out to happen at 70px from the bottom of the parent element. and for it to stay at that position, relative to the parent as I continue to scroll down the page.

@rahulv3a
Copy link

+1

@daxhns
Copy link

daxhns commented Nov 26, 2016

+1

I also need offset_bottom option. I need to bottom out the element 100px "before" the parent element is scrolled out.

@solid-pixel
Copy link

solid-pixel commented Mar 31, 2017

I know this is old but I was looking for the same thing, and I've managed to work around this lack of bottom offset by adding some margin/padding at the bottom of the sticky element.

edit: forget it, it doesnt work.
It's a shame the developer doesn't care anymore, it was good until it lasted :(

@iamtekeste
Copy link

I am looking for exactly this!

@iamtekeste
Copy link

I just found this MR but it looks like it is not going to be merged in any time soon.
#62

@dwoznicka
Copy link

+1. doesn't seem like the project is still maintained though

@alessandro-newzoo
Copy link

Assuming a structure like this:

<div class="sticky-title">
	
    <h4>Title</h4>
    <p>Subtitle</p>

</div>

Just create a pseudo element after the p:

p:after {
    content: '';
    display: block;
    height: 100px; /** this is your bottom offset **/
}

This hack allows for a bottom offset of 100px.

@fiazmr2
Copy link

fiazmr2 commented Feb 19, 2021

To bottom out at n pixel i think you need to set your parent scroll track element height to that much pixels, and then call the stick_in_parent API on that parent
sticky-kit bottom out n pixels

I had the issue with sticky container kept on scrolling till and not bottom out at all, its then when i recognised that the parent height was same as the sticky container to be scrolled. I set height of the parent container as long as the length of the track and calling sticky it API with parent it worked.

$('.sticky-right').stick_in_parent({ offset_top: 82, parent: ".product-main_content", recalc_every: 1 });

Without setting my parent track height, calling the API my sticky container was added with .is_stuck as
position: absolute;
height: auto;

which shouldn`t be the case. When track height is set correctly it will be added with styles as
position: fixed;
height: {offset_top used in API call};

@hadiMh
Copy link

hadiMh commented Aug 19, 2021

Hi,
Based on the above answers this library is not going to get updated.
So I want to share my simple trick that worked for me:

We want to add some margin to the bottom of the sidebar that is sticky...
Instead of working on the existing elements or the library options there is another way.
The library works for any

so we just need to add a little more height to the div but by a hidden element.
For example I added a new
with the height of 20px as the last child of the side bar.
To clear out, the code looks like something like this:

<div class="sidebar">
    <div> .... </div>
    <some other element> ... </>
    <div class="space"></div>
</div>

and

.space {
    height: 20px;
}

so the sticky-kit library wants to make it scrollable and sticky so some space appears on the bottom looking like some margin.

Well... That works for me :)

It is a very simple solution. But I hope it was helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants