Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/heimrichhannot/scroll-toggle

Simple javascript plugin to toggle elements on scroll.
https://github.com/heimrichhannot/scroll-toggle

Last synced: about 1 month ago
JSON representation

Simple javascript plugin to toggle elements on scroll.

Awesome Lists containing this project

README

        

# Scroll-Toggle

Simple javascript plugin to toggle elements on scroll. The styling to hide and show elements must be done by yourself.

![demo](https://raw.githubusercontent.com/heimrichhannot/scroll-toggle/master/docs/assets/scroll-toggle-demo.gif "Scroll Toggle Demo")

## Usage

Require the plugin itself.

`require('ScrollToggle');`

By default the plugin listens on elements with the `.scroll-toggle` css class.

```


```

In order to hide elements, you can use the following scss snippet and customize for your needs:

```
.scroll-toggle {
transition: transform 250ms linear;
transform: translateY(0);
&.scroll-hide {
transform: translateY(100%);
}
}
```

## Additional Attributes

| Attributes | Description |
|---|---|
| data-offset | Set a minimum offset to start hide element (body scrollTop), can also be an valid CSS-Selector like `#header` |
| data-body-class | Define a custom CSS class that should be toggled on body element on hide/show element. |
| data-init-show | Set to false if you want to hide the element initially, if offset is below body scrollTop on load. |