Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/evanminto/sticky-sentinel-element


https://github.com/evanminto/sticky-sentinel-element

Last synced: 6 days ago
JSON representation

Awesome Lists containing this project

README

        

# Sticky Sentinel Element

Custom element implementation of the technique described in this
Google Developers article:
https://developers.google.com/web/updates/2017/09/sticky-headers

Documentation is still a work in progress.

## Usage

There's a no-config option for simple use cases:

```html


```

Style the sticky element based on the `stuck` state of the sentinel:

```css
sticky-sentinel[stuck] ~ .sticky-element {
/* Add your stuck styles here. */
}
```

You can also reference the target element explicitly and set a class on it
directly when it becomes stuck:

```html


```

```css
.sticky-element.stuck {
/* Add your stuck styles here. */
}
```

**Important:** The sentinel must be placed such that its top edge lines up with
the top edge of the sticky element. The easiest way to do this is to place the
sticky element directly after the sentinel as a sibling.