sticky-kit icon indicating copy to clipboard operation
sticky-kit copied to clipboard

Use scrollTop of parent_selector instead of window?

Open nowherenearithaca opened this issue 7 years ago • 2 comments

Hi

The current implementation seems to assume you care about scrolltop of the window, and I want it to be within the parent.

I changed the calcs to use the scrollTop of the (specified) parent and it seemed to work, but was wondering if there a way to do this without messing the code.

thanks!

nowherenearithaca avatar Feb 26 '18 23:02 nowherenearithaca

Hi,

Do you mind sharing your modified code?

papa-zulu avatar Mar 11 '19 08:03 papa-zulu

Yes I find myself needing this functionality too. Currently my workaround is something like:

$('.sticky').stick_in_parent({
    offset_top: $('.sticky').parent().get(0).getBoundingClientRect().top,
});
$('.sticky').parent().scroll(function () {
    $(document.body).trigger('sticky_kit:recalc');
});

keith0305 avatar Feb 20 '20 09:02 keith0305