New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

scroll-visibility-js

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scroll-visibility-js

ES6 module that monitors elements in the document and flags them whenever they enter the viewport.

latest
Source
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

Scroll-Visibility-JS

To add this package to your next project, simply download /view.js or run npm install scroll-visibility-js –save-dev and import it.

When importing and initializing the package, you can invoke one of two modules: "_util" (obj) or "ScrollView" (class).


import { ScrollView, _util as scroll } from 'scroll-visibility-js';

const newScrollObject = new ScrollView({
  callback: () => console.log(this), // this represents the inview element
  offset: 0,
  repeat: true 
});

const element1 = document.getElementById('demo');
const element2 = document.getElementById('demo');

scroll.fromTop(element1); // returns boolean
scroll.progress(element1); // returns num from 0 to 100
scroll.overlap(element1, element2 ); // returns boolean
scroll.scrollPostion(); // returns pixel quantity
scroll.visibility(element2); // returns boolean

By default, the module targets data-scrollvisibility elements and inserts their initial values as the animation-driving class. For instance, the element <a href="#" data-scrollvisibility="fadeIn"></a> will become <a href="#" class="fadeIn" data-scrollvisibility="true"></a> once in the viewport. Thus, it's best to structure your scss file in the following manner to perform scroll-based effects:


[data-scrollvisibility]{
  opacity: 0;
  visibility: hidden;
  
  &.fadeIn {
    transition: all 350ms ease-in-out;
    transform: translateY(100px);  
  }
  
}

[data-scrollvisibility="true"]{
  opacity: 1;
  visibility: visible;
  
  &.fadeIn {
    transform: translateY(0);
  }
  
}


Keywords

scroll

FAQs

Package last updated on 07 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts