rippleJS

vanilla Material Design ripples

Github星跟蹤圖

rippleJS

Adds Material Design-style feedback ripples to your existing HTML without any dependencies.
Show me the demos!

Usage

Include the rippleJS script (or use a local copy).
Then, add elements with the rippleJS class within a parent element that has layout (aka, position: relative or position: absolute).

<button class="yourButton">
  Click Me
  <div class="rippleJS"></div>
</button>

<script async src="https://cdn.jsdelivr.net/npm/vanilla-ripplejs@1.0.6"
    integrity="sha384-OlarGErerEgz/M7123pQTTek4pUIiR6t0BK09bTmWDi2cZYbv3VHrriaXDnA0Oup"
    crossorigin="anonymous"></script>
<!-- or if using ES6 modules -->
<script type="module">
  import 'https://cdn.jsdelivr.net/npm/vanilla-ripplejs@1.0.6';
</script>

rippleJS adds handlers on document.body, so you don't need to register any new elements as you add them to the DOM.
It supports touch and mouse events (even at the same time), and includes its own CSS.

Ripple Fill

By adding the fill class to a rippleJS element, the ripple will fill to rounded corners, good for form elements with fixed size.
For example:

<div class="optHolder">
  <input type="checkbox" />
  <div class="rippleJS fill"></div>
</div>

Ripple Color

The default color is a transparent version of the current color (aka, the currentColor keyword).
To change this default, add the following style rule:

.rippleJS .ripple {
  background: red;
}

You could also change it just for some elements:

.yourClassName .rippleJS .ripple {
  background: blue;
}

Or change the level of opacity:

.moreOpaque .rippleJS .ripple {
  opacity: 0.65;
}

Supports

Chrome, Safari, Firefox (all as of Dec 2014).
Requires classList, so probably only supports IE10+.

Install

Instead of using rippleJS directly, you can fetch it using your favourite package manager:

$ bower install vanilla-ripplejs
$ npm install vanilla-ripplejs

You can either use ripple.min.js for a precompiled version to just drop into your site, or you could use lib.js included as a ES module.
If you use lib.js, you'll need to include the CSS too—check out ripple.js for how this is done for the minified version, or you could just add the CSS to your regular styles.

主要指標

概覽
名稱與所有者samthor/rippleJS
主編程語言JavaScript
編程語言CSS (語言數: 3)
平台
許可證MIT License
所有者活动
創建於2014-12-13 22:16:01
推送於2018-09-22 14:52:37
最后一次提交2018-09-23 00:52:16
發布數6
最新版本名稱v1.0.5 (發布於 )
第一版名稱v1.0.0 (發布於 )
用户参与
星數192
關注者數4
派生數17
提交數55
已啟用問題?
問題數12
打開的問題數5
拉請求數2
打開的拉請求數0
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?