Ripple.JS (GitHub | Demo | CDN) adds a Material style ripple to HTML Elements like this:
<!-- language: lang-js -->$.ripple(".btn", {
on: 'mousedown', // The event to trigger a ripple effect
opacity: 0.4, // The opacity of the ripple
color: "auto", // Set the background color. "auto" will use the text color
duration: 0.7, // The duration of the ripple
easing: 'linear' // The CSS3 easing function of the ripple
});
Q: Is there a way to programmatically invoke this?
Demo in jsFiddle & Stack Snippets
<!-- begin snippet: js hide: true console: true babel: false --> <!-- language: lang-js -->$.ripple(".btn", {
on: 'mousedown', // The event to trigger a ripple effect
opacity: 0.4, // The opacity of the ripple
color: "auto", // Set the background color. "auto" will use the text color
duration: 0.7, // The duration of the ripple
easing: 'linear' // The CSS3 easing function of the ripple
});
<!-- language: lang-css -->
body {
padding: 15px;
}
<!-- language: lang-html -->
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/paper/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/Ripple.js/1.2.1/ripple.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Ripple.js/1.2.1/ripple.js"></script>
<button class="btn btn-primary btn-lg" >Click Me</button>
<!-- end snippet -->