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

mat-ripple

v1.0.4

Published

Material design Ripple effect.

Downloads

223

Readme

MatRipple

Material design Ripple effect.

npm version npm dependencies devDependencies Status bundle size Known Vulnerabilities

Install

NPM
$ npm i mat-ripple
CDN
<script src="https://unpkg.com/mat-ripple"></script>

Import

// ES6
import MatRipple from 'mat-ripple';

// CommonJS
const MatRipple = require('mat-ripple');

Usage

MatRipple is a customElementso it can be used directly in the html like so <mat-ripple>

<div id="container">
	<button id="myAwesomeBtn">
		Click me
		<mat-ripple />
	</button>
</div>

or

// ES6
import MatRipple from 'mat-ripple';

let myAwesomeBtn = document.getElementById('myAwesomeBtn');
let ripple = new MatRipple();

myAwesomeBtn.appendChild(ripple);

Properties

| Name | Type | Default | Description | | --------- | ------- | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | color | string | #00000033 | Custom color or any valid CSS background property for all ripples. | | unbounded | boolean | false | Whether the ripples should be visible outside the component's bounds. | | disabled | boolean | false | Whether click events will not trigger the ripple. Ripples can be still launched manually by using the launch method. | | centered | boolean | false | Whether the ripple always originates from the center of the host element's bounds, rather than originating from the location of the click event. | | radius | number | 0 | If set, the radius in pixels of foreground ripples when fully expanded. If unset, the radius will be the distance from the center of the ripple to the furthest corner of the host element's bounding rectangle. |

<div id="container">
	<button id="myAwesomeBtn">
		Click me
		<mat-ripple color="#49b3a533" disabled centered unbounded radius="70" />
	</button>
</div>

API

// ES6
import MatRipple from 'mat-ripple';

let myAwesomeBtn = document.getElementById('myAwesomeBtn');
let container = document.getElementById('container');

let ripple = new MatRipple();
/**
 * Custom color or any valid `CSS` background property for all ripples.
 * @default `rgba(0,0,0,.2)`.
 */
ripple.color = '#ff000033';

/**
 * Set whether the ripple always originates from the center of the host element's bounds, rather
 * than originating from the location of the click event.
 * @default false
 */
ripple.centered = true;

/** Set whether the ripples should be visible outside the component's bounds.
 * @default false
 */
ripple.unbounded = true;

/**
 * If set, the radius in pixels of ripples when fully expanded.
 * If unset, the radius will be the distance from the center of the ripple
 * to the furthest corner of the host element's bounding rectangle.
 * @default 0
 */
ripple.radius = 70;

/**
 * whether click events will not trigger the ripple.
 * @default false
 */
ripple.disabled = false;

/**
 * Configuration for the ripple animation.
 * Allows modifying the enter and exit animation duration of the ripples.
 * The animation durations will be overwritten if the NoopAnimationsModule is being used.
 */
ripple.animation = {
	/**
	 * Duration in milliseconds for the enter animation (expansion from point of contact).
	 * @default 450
	 */
	enterDuration: 5000,
	/**
	 * Duration in milliseconds for the exit animation (fade-out).
	 * @default 400
	 */
	exitDuration: 1000,
};

/**
 * The element that triggers the ripple when click events are received.
 * @default the host element.
 */
ripple.trigger = container;

myAwesomeBtn.appendChild(ripple);

Global options

Instantiate MatRipple using global options.

// ES6
import MatRipple from 'mat-ripple';

const globalOptions = {
	/**
	 * Whether ripples should be disabled. Ripples can be still launched manually by using
	 * the `launch` method. Therefore focus indicators will still show up.
	 * @default false
	 */
	disabled: false,

	/**
	 * Configuration for the animation duration of the ripples. There are two phases with different
	 * durations for the ripples.
	 */
	animation: {
		/**
		 * Duration in milliseconds for the enter animation (expansion from point of contact).
		 * @default 450
		 */
		enterDuration: 5000,

		/**
		 * Duration in milliseconds for the exit animation (fade-out).
		 * @default 400
		 */
		exitDuration: 1000,
	},

	/**
	 * Whether ripples should start fading out immediately after the mouse or touch is released. By
	 * default, ripples will wait for the enter animation to complete and for mouse or touch release.
	 * @default  false
	 */
	terminateOnPointerUp: false,
};

const ripple = new MatRipple(globalOptions);

Methods

/**
 * Launches a manual ripple at the specified coordinates within the element.
 * @param x Coordinate within the element, along the X axis at which to fade-in the ripple.
 * @param y Coordinate within the element, along the Y axis at which to fade-in the ripple.
 * @param config Optional ripple configuration for the manual ripple.
 */
launch(x, y, config);

/**
 * Fades out all currently showing ripple elements.
 */
fadeOutAll();

Demo

A simple demo using the UMD version.

License

MIT