Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Support "stickyBitStickyOffset" as a function so it is recalculated dynamically. #544

Open
dpoltoratsky opened this issue Jun 25, 2019 · 1 comment

Comments

@dpoltoratsky
Copy link

dpoltoratsky commented Jun 25, 2019

Requested Update

Support "stickyBitStickyOffset" (and potentially other props) as a function, so it is recalculated dynamically.

Why Is This Update Needed?

To support use cases when sticky element position may change due to changes on the page.

For example, going through a responsive breakpoint makes the base font size smaller/larger, which affects the height of an element above the sticky one.

Below is example from my implementation with jQuery.

const $adminBar = $('#wpadminbar');
const $header = $('#masthead');

$header.sticky({
        useStickyClasses: true,
        stickyBitStickyOffset: () =>
            - $header.children('.site-branding').outerHeight()
            + ($adminBar.length ? $adminBar.outerHeight() : 0)
    });

In my particular case, the height of the .site-branding changes dynamically when going through responsive breakpoints.

Are There Examples Of This Requested Update Elsewhere?

I am not sure, does not seem so.

@yowainwright
Copy link
Contributor

Although, I think this change could help and be fun to make. However, it reads like the problem could be solved within a resize callback.

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

No branches or pull requests

2 participants