1.1.1 • Published 5 years ago

@hundh/scroll-toggle v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Scroll-Toggle

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

demo

Usage

Require the plugin itself.

require('ScrollToggle');

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

<div class="nav-quick scroll-toggle" data-offset="#header" data-body-class="nav-quick-hidden" data-init-show="true">
</div>

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

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