Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/mnr73/js-sticky-side

create sticky element in flexbox sidebars. it can use in Vanilla JS and frameworks like Vue and React
https://github.com/mnr73/js-sticky-side

Last synced: about 1 month ago
JSON representation

create sticky element in flexbox sidebars. it can use in Vanilla JS and frameworks like Vue and React

Awesome Lists containing this project

README

        

# js sticky side

simple sticky side with js that can use in frameworks like vue and react.

![sticky side with javascript](/files/preview.GIF "js sticky side")

## notes

- it can be used just in flexbox grids.
- target element should be parent flexbox and it should have just one child.
- the child should not have bottom margin.

## how to use

install it with this command.

`npm i js-sticky-side`

import that in your code.

`import { sticky } from "js-sticky-side"`

create object and use it

`var stickySide = new sticky(parentElement, int topOffest, int bottomOffset, int screenWith);`

- **parentElement** : the parent element that should be flexbox
- **topOffest** : sticky child space to top (default 0)
- **bottomOffset** : sticky child space to bottom (default 0)
- **screenWith** : minimum screen size that sticky should be active (default 0)

## example

```js
var stickySide = new sticky(document.querySelector("#sticky-parent"), 80, 20, 768);

window.addEventListener("scroll", stFunction);

function stFunction() {
stickySide.sticky();
}
```