0.1.7 ā€¢ Published 7 years ago

awesome-scroll v0.1.7

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

awesome-scroll

A simple and fast container to monitor elements as you scroll https://stephenkingsley.github.io/stress.html

BASIC USAGE

first

npm install awesome-scroll --save

and in your code

import awesomeScroll from "awesome-scroll";

const scrollElement = document.getElementById("scrollElement");
const watcherElement = awesomeScroll.create(scrollElement);

const addClass = () => {
  if (!this.isInViewport) {
    return;
  } else if (this.isFullyInViewport) {
    this.watchItem.style.backgroundColor = '#fcc';
  } else if (this.isAboveViewport) {
    this.watchItem.style.backgroundColor = '#ccf';
  } else if (this.isBelowViewport) {
    this.watchItem.style.backgroundColor = '#ffc';
  }
}

watcherElement.stateChange(addClass);

DEMO

šŸ‘‡ localhost demo

git clone https://github.com/stephenkingsley/awesome-scroll.git

cd awesome-scroll

npm i

npm run dev

open http://localhost:3000

there are some example in /example folder

0.1.7

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago