All Projects → virtyaluk → Paper Ripple

virtyaluk / Paper Ripple

Licence: mit
Material Design Ripple effect in pure JS & CSS.

Programming Languages

javascript
184084 projects - #8 most used programming language
js
455 projects

Projects that are alternatives of or similar to Paper Ripple

Smelte
UI framework with material components built with Svelte and Tailwind CSS
Stars: ✭ 871 (+1483.64%)
Mutual labels:  material-design, material
Jtmaterialtransition
An iOS transition for controllers based on material design.
Stars: ✭ 966 (+1656.36%)
Mutual labels:  material-design, material
Vuetify
🐉 Material Component Framework for Vue
Stars: ✭ 33,085 (+60054.55%)
Mutual labels:  material-design, material
Awesomebar
Just beautiful
Stars: ✭ 870 (+1481.82%)
Mutual labels:  material-design, material
Quasar Awesome
🎉 A list of awesome things related to Quasar
Stars: ✭ 995 (+1709.09%)
Mutual labels:  material-design, material
Material Components
Documentation and policies for Material Components (all platforms)
Stars: ✭ 872 (+1485.45%)
Mutual labels:  material-design, material
React Saas Template
🌊 Template for building an SaaS / admin website using React + Material-UI
Stars: ✭ 942 (+1612.73%)
Mutual labels:  material-design, material
Materialdesignsamples
Material Design 系列控件samples,讲了Material Design 系列新控件的使用方法和一些场景示例,使用详情请看对应博客,持续更新中...
Stars: ✭ 900 (+1536.36%)
Mutual labels:  material-design, material
Alfred Mdi
Alfred 3 workflow to find Material Design Icons
Stars: ✭ 38 (-30.91%)
Mutual labels:  material-design, material
Materialsearchview
Android Search View based on Material design guidelines.
Stars: ✭ 987 (+1694.55%)
Mutual labels:  material-design, material
React Native Material Textfield
Material textfield
Stars: ✭ 852 (+1449.09%)
Mutual labels:  material-design, material
Android Dev
⚡️ Curated list of resources for Android app development. Prepare for battle!
Stars: ✭ 44 (-20%)
Mutual labels:  material-design, material
Mdwechat
一个能让微信 Material Design 化的 Xposed 模块
Stars: ✭ 849 (+1443.64%)
Mutual labels:  material-design, material
Bootstrap
Open Source JS plugins
Stars: ✭ 13 (-76.36%)
Mutual labels:  material-design, jquery
Breeze
A Material Design game launcher for Windows
Stars: ✭ 22 (-60%)
Mutual labels:  material-design, material
Material Design Lite
Material Design Components in HTML/CSS/JS
Stars: ✭ 31,931 (+57956.36%)
Mutual labels:  material-design, material
Matter
Material Design Components in Pure CSS. Materializing HTML at just one class per component 🍰
Stars: ✭ 888 (+1514.55%)
Mutual labels:  material-design, material
Mdl Skeleton
Material Design skeleton with ssr-engine
Stars: ✭ 17 (-69.09%)
Mutual labels:  material-design, material
Bluetooth State View
Material design animated Bluetooth state view for Android
Stars: ✭ 36 (-34.55%)
Mutual labels:  material-design, material
Material Motion
Starmap and team docs
Stars: ✭ 44 (-20%)
Mutual labels:  material-design, material

mutation-watcher
PaperRipple v0.3.0

Build Status Code Climate Dependency Status ESDoc Coverage

Material Design Ripple effect in pure JS & CSS.

PaperRipple lets you add a Material Design ripple effect to UI elements.

📀 Install

Bower:
$ bower install paper-ripple
NPM:
$ npm install paper-ripple --save

How it looks like

Live example at codepen.

📋 Usage

First, you need to include PaperRipple JS and CSS files to your HTML-page.

Assume, you have next HTML:

<button class="paper-button">button</button>
<button class="paper-button blue-text">button</button>
<button class="paper-button orange-text">button</button>

Your JS will look like:

// // Getting all the buttons
var button = document.querySelectorAll('button.paper-button');

// Traversing the buttons
[].forEach.call(buttons, function(button) {
	// New PaperRipple for the button
	var ripple = new PaperRipple();
	
	// Adding ripple container to the button
	button.appendChild(ripple.$);

	// Subscribing to 'mousedown' and 'mouseup' button events to activate ripple effect
	// when a user clicks on the button.
	button.addEventListener('mousedown', function(ev) {
		ripple.downAction(ev);
	});
	button.addEventListener('mouseup', function() {
		ripple.upAction();
	});
});

NOTE: It's important that each element you add the ripple to must be relative position.

If you prefer to work with modules in JS, PaperRipple exports itself in AMD, CommonJS and as global variable if no require or module were found. In addition, under dist\systemjs you may find PaperRipple as SystemJS module.

Even more, if you prefer to work with jQuery you may find jQuery plugin based on PaperRipple under dist folder. So, the previous example may be simplified to the next:

$('button.paper-button').paperRipple();

Configuration

You may pass additional options to the constructor to control PaperRipple behavior:

var ripple = new PaperRipple(cfg);

If you have DOM element you want to use as PaparRipple element, pass it to the constructor. But be careful, PaperRipple element must follow next structure:

<div class="paper-ripple">
	<!-- optional -->
	<div class="paper-ripple__background"></div>

	<!-- optional -->
	<div class="paper-ripple__waves"></div>
</div>
var rippleEl = document.querySelector('.paper-ripple'),
	ripple = new PaperRipple(rippleEl);

assert(ripple.$ === rippleEl); // true

Or you may pass object containing next options:

  • initialOpacity: Number - Defaults to 0.25. The initial opacity of the each wave.
  • opacityDecayVelocity: Number - Defaults to 0.8. How fast (opacity per second) the wave fades out.
  • recenters: Boolean - Defaults to false. If true, waves will exhibit a gravitational pull towards the center of their container as they fade away.
  • center: Boolean - Defaults to false. If true, waves will center inside its container.
  • round: Boolean - Defaults to false. If true, ripple effect will apply within a circle.
  • target: HTMLElement - Defaults to null. Target DOM element as the container for the waves.
var ripple = new PaperRipple({
	initialOpacity: 0.3,
	recenters: true
});

Each of these options may be changed after initializing:

ripple.center = true;
ripple.opacityDecayVelocity = 0.7;

NOTE: Changing of $, $background or $waves after initialization not recommended.

Styling

Use CSS color property to style the ripple:

.paper-ripple {
	color: #FF9800;
}

NOTE: CSS color property is inherited so it is not required to set it on the .paper-ripple directly.

📗 Browser Support

  • Chrome
  • Firefox
  • Safari
  • Opera
  • IE9+

NOTE: IE9 doesn't support classList on HTMLElement object and requestAnimationFrame. You need to polyfill it. My choice: classList - bower install classlist or npm install classlist-polyfill; requestAnimationFrame - bower install window.requestanimationframe or npm install window.requestanimationframe.

🎓 Docs

PaperRipple JS has an excellent documentation. Esdoc is used to generate it. To generate it by yourself do following:

Clone the repo:

$ git clone https://github.com/virtyaluk/paper-ripple.git

Install dependencies:

$ npm install -g gulp && npm install

Generate the docs:

$ gulp docs

Docs will be available under docs folder in the root of the project.

Running tests

Install dependencies:

$ npm install

Run them:

$ gulp test

📆 Changelog

0.2.0 (December 07, 2015)

  • Added new round property on main PaperRipple class.

0.3.0 (June 01, 2017)

📗 License

Licensed under the MIT license.

Copyright (c) 2017 Bohdan Shtepan


modern-dev.com  ·  GitHub @virtyaluk  ·  Twitter @virtyaluk

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].