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

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

@dpoltoratsky

Description

@dpoltoratsky

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions