1.0.1 • Published 5 years ago

@sil/scroll-menu v1.0.1

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

Scroll Trigger

A simple Vue Directive to trigger a class based on the element inview or not.

Install

Install the package npm install @sil/scroll-menu

Import the package

import ScrollMenu from '~/@sil/scroll-menu

Define the component:

	Vue.directive(ScrollMenu);

Use the component with default values:

<any-element v-scroll-menu />	

Use the component with alternative values:

<element v-scroll-menu="{bemClass: 'header', setClasses: true, offset: 80 }" ></element>

Styling

Some styling won't be set automatically. Don't forget to add this to your element.

.element {
	position: fixed;
	top: 0;
	width: 100%; 

	transition: transform 0.5s ease-in-out;
	will-change: transform;

	// In case of opacity change:
	transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out; 
	will-change: transform, opacity; 
}

Settings

ArgumentDefaultDescription
debugfalseShow debugging logs
offset0On/Off top is triggered from the top (+ offset) of the page.
bemClassnullGive a bemclass to automatically created BEM style classes
setStyletrueSets the transform and opacity (when opacity is true)
setClassesfalseSets the classes to the element. So you can style more on the given parameters.

Classes

ArgumentDefaultDescription
offClass.offClass given when the element is from the top
onClass.onClass given when the element is on the top
upClass.upClass given when page is scrolling up
downClass.downClass given when page is scrolling down

bemClass

When set, the element, classes will be overruled and automatically set with the given bemClass (string):

The end of the classes (up,down,etc..) are being used from the 'classes'.

  • up: [bemClass]--up
  • down: [bemClass]--down
  • off: [bemClass]--off
  • on: [bemClass]--on

default: null