Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vanilla-fade

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vanilla-fade

VanillaJS implementation of the JQuery fade methods.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Vanilla JS - fade   ko-fi

npm version David David Build Status Greenkeeper badge semantic-release Commitizen friendly Contributor Covenant

Simple Vanilla JS implementation of the fadeIn(), fadeOut(), fadeTo() and fadeToggle() methods. This little package once loaded will add the mentioned methods to the Element prototype. All of the above methods accept the same paramaters: [duration, easing, complete]. Furthermore the prefers-reduce-motion is natively supported. You can read more about it here.


Find this usefull? ☕ Buy me a coffee!


Installation

This package can be downloaded from the NPM registry npm install vanilla-fade --save. Or included in via a standard script tag from this url. Once imported it will automatically initialize.

// IIFE
<script src="https://unpkg.com/vanilla-fade/dist/vanilla-fade.js">

// CJS
require('vanilla-fade/cjs'); // all the library
require('vanilla-fade/cjs/fadeIn'); // single animation
require('vanilla-fade/cjs/fadeOut'); // single animation
require('vanilla-fade/cjs/fadeToggle'); // single animation
require('vanilla-fade/cjs/fadeTo'); // single animation

// ESM
import 'vanilla-fade/esm'; // all the library
import 'vanilla-fade/esm/fadeIn'; // single animation
import 'vanilla-fade/esm/fadeOut'; // single animation
import 'vanilla-fade/esm/fadeToggle'; // single animation
import 'vanilla-fade/esm/fadeTo'; // single animation

Usage

After import the package the Element.prototype.fadeIn(), Element.prototype.fadeOut(), Element.prototype.fadeTo() and Element.prototype.fadeToggle() will be available to use. The methods accepts the following paramenters:

Element.fadeIn(duration = 250, easing = 'linear', complete = null)
Element.fadeOut(duration = 250, easing = 'linear', complete = null)
Element.fadeTo(duration = 250, opacity = NaN, easing = 'linear', complete = null)
Element.fadeToggle(duration = 250, easing = 'linear', complete = null)
  • duration can be a number or a string representing and integer of milliseconds.
  • opacity final opacity value. Required only in fadeTo
  • easing should be one of the following string: [linear, quadratic, swing, circ, bounce].
  • complete is a callback that will be executed after the animation completes.

The Element display property won't change after fading out. No assumption on the original display value or opacity value are made. Once triggered the opacity will go from 0 -> 1 and viceversa. So if the element original opacity was .5 this value won't be considered when toggling the fading effect.

Browser support

Babel will automatically transpile according to the following browserslist:

# Browsers that we support

defaults

Keywords

FAQs

Package last updated on 27 Apr 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc