npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sa-reveal

v1.0.6

Published

The `RevealDirective` is an Angular directive that allows elements to reveal themselves during scrolling, with customizable direction, delay, and animation speed.

Downloads

10

Readme

Reveal

The RevealDirective is an Angular directive that allows elements to reveal themselves during scrolling, with customizable direction, delay, and animation speed.

Features

  • Reveal elements as they come into view during scrolling.
  • Control the direction of the reveal animation ('b', 't', 'r', 'l',.....).
  • Set a delay for the reveal animation.
  • Control of animation scroll.
  • Customize the speed of the reveal animation using a CSS variable.
  • Customize the animation type using a CSS variable.

Installation

To install the library via npm:

npm install sa-reveal

To use the library directly in a static HTML file, include the following script tag in your HTML:

<script src="https://reveal.devahmedabdo.workers.dev/"></script>
<script>
  window.addEventListener("DOMContentLoaded", () => {
    reveal("b", 50, false); // Customize the options as needed
  });
</script>
  • First parameter: Reveal type (e.g., 'b' for bottom, 't' for top, etc.)
  • Second parameter: Offset (number in pixels to control when the reveal starts)
  • Third parameter: to prevent animation to replay more one time.

Usage

Add css files

Add the path to the library CSS files in angular.json as follows:

 "styles": ["node_modules/sa-reveal/src/assets/reveal.css"],

1. Import the directive

First, you need to import the directive into your Angular project.

import { RevealDirective } from "sa-reveal";

2. Add to Component Template

Add the reveal directive to any element in your component’s HTML template. You can control the direction and delay of the reveal using the reveal and delay inputs.

<div reveal="b" [delay]="2">Content to reveal</div>

3. Control the speed

You can of the reveal animation by setting a CSS variable. Add this CSS to your styles:

:root {
  --reveal-speed: 1s;
}

By default, the reveal speed is set to 0.5s. You can change this value to suit your needs.

Basic Usage

<div reveal>
  <!-- Your content here -->
</div>

Custom Directions

You can specify custom directions using the reveal attribute. Available options are:

  • r (right)
  • l (left)
  • t (top)
  • b (bottom) - Default
  • tr (top-right)
  • tl (top-left)
  • br (bottom-right)
  • bl (bottom-left)
<div reveal="r">
  <!-- Animates from the right -->
</div>

Zoom and Flip Animations

You can also apply zoom and flip effects:

  • zi (zoom in)
  • zo (zoom out)
  • fl (flip left)
  • fr (flip right)
  • fb (flip bottom)
  • ft (flip top)
<div reveal="zi">
  <!-- Zoom in animation -->
</div>

Clip Path Animations

For clip path animations, use:

  • cr (clip right)
  • cl (clip left)
  • ct (clip top)
  • cb (clip bottom)
  • cc (clip circle)
  • cs (clip star)
<div reveal="cc">
  <!-- Circular clip animation -->
</div>

Split Animations

For clip path animations, use:

  • si (Split inline)
  • sio (Split inline out)
  • sb (Split block)
  • sbo (Split block out)
  • st (Split tendon)
  • sto (Split tendon out)
<div reveal="cc">
  <!-- Circular clip animation -->
</div>

Filters

You can apply filter effects like blur, brightness, grayscale, and more:

  • blur (blur animation)
  • light (brightness increase)
  • dark (brightness decrease)
  • color (grayscale)
<div reveal="blur">
  <!-- Blur animation -->
</div>

Configuration

Global Configuration

You can set default properties for all reveal elements in your app by providing a configuration in your module:

{
  provide: RevealService,
  useValue: {
    reveal: 'b' as Reveal,  // Default direction
    endScroll: false,       // Scroll behavior
    offset: 100,            // Offset from viewport to trigger
  },
}

endScroll Behavior

The endScroll property controls whether the animation should replay each time the element enters the viewport. If endScroll is true, the animation will trigger only once and stop. If false, the animation will trigger every time the element enters the viewport.

  • Default: false

offset Value

The offset defines the distance in pixels before the element enters the viewport to trigger the animation. You can set a custom offset value for individual elements or globally.

  • Default: 100

Custom Animation Speed

You can set the speed of the animation using the --reveal-speed CSS variable. Apply it globally to the body or individually to elements:

body {
  --reveal-speed: 1s; /* Default: 0.5s */
}

Or for individual elements:

<div reveal style="--reveal-speed: 1s;">
  <!-- Custom speed for this element -->
</div>

Custom Animation Type

You can set the animation type using the --reveal-type CSS variable. Apply it globally to the body or individually to elements:

body {
  --reveal-type: cubic-bezier(0.46, -1.53, 0.47, 2.92); /* Default: ease-in-out */
}

Or for individual elements:

<div reveal style="--reveal-type:ease-in;">
  <!-- Custom type for this element -->
</div>

[!IMPORTANT]
To prevent horizontal scrolling issues, please ensure you add overflow: hidden; to the first parent element. Note that overflow-x is not supported in all browsers.

License

MIT License