1.0.7 • Published 6 years ago

modularscroll v1.0.7

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

Installation

npm install modularscroll

Why

  • Simple
  • Lightweight
  • High performance
  • No dependencies

Usage

import modularScroll from 'modularscroll';

this.scroll = new modularScroll();
<h1 data-scroll>Hello</h1>
<p data-scroll>Text</p>

With options

import modularScroll from 'modularscroll';

this.scroll = new modularScroll({
    el: document,
    name: 'scroll',
    class: 'is-inview',
    offset: 0,
    repeat: false
});
<h1 data-scroll data-scroll-repeat>Hello</h1>
<p data-scroll data-scroll-offset="60">Text</p>

With methods

import modularScroll from 'modularscroll';

this.scroll = new modularScroll();

this.scroll.update();

With events

import modularScroll from 'modularscroll';

this.scroll = new modularScroll();

this.scroll.on('call', (func) => {
    this.call(...func); // Using modularJS
});
<div data-scroll data-scroll-call="function, module">Trigger</div>

Options

OptionTypeDefaultDescription
elobjectdocumentScroll container element.
namestring'scroll'Data attributes name.
classstring'is-inview'Elements in-view class.
offsetnumber0In-view trigger offset.
repeatbooleanfalseRepeat in-view detection.

Attributes

AttributeValuesDescription
data-scrollDetect if in-view.
data-scroll-classstringElement in-view class.
data-scroll-offsetnumberElement in-view trigger offset.
data-scroll-repeattrue, falseElement in-view detection repeat.
data-scroll-callstringElement in-view trigger call event.

Methods

MethodDescription
init()Reinit the scroll.
update()Update elements position.
destroy()Destroy the scroll events.

Events

EventArgumentsDescription
callfuncTrigger if in-view. Returns your string or array if contains ,.
1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago