Bootstrap Material Design

Bootstrap Material Design

by Ayyappan Sakthivadivel

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <!-- the button -->
        <a class="btn btn-primary">Ripple Button Test</a>
        <input type="submit" class="btn btn-primary" value="Ripple Button Test input btn" />
        <button type="submit" class="btn btn-primary">Ripple Button Test btn</button>
    <!-- end -->

CSS

.btn{
  position: relative;
  overflow: hidden;
  -webkit-box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.4);
  -moz-box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.4);
  box-shadow: 0px 1px 5px 0px rgba(50, 50, 50, 0.4);
  -webkit-transform: rotate(0.000001deg);
}

.drop{
  display: block;
  border-radius: 90%;  
  opacity: 0.5;
  position: absolute;
  background: #fff;
    -moz-transform: scale(0);
    -webkit-transform: scale(0);
    transform: scale(0);
}

.drop.animate {
  -webkit-animation-name: ripple;
  -webkit-animation-duration: 0.65s;
  -webkit-animation-timing-function: linear;
  
  -moz-animation-name: ripple;
  -moz-animation-duration: 0.65s;
  -moz-animation-timing-function: linear;
}

@-webkit-keyframes ripple {
  100% {
      opacity: 0; 
        -moz-transform: scale(2.5); 
        -webkit-transform: scale(2.5); 
        transform: scale(2.5); 
        border-radius: 90%;
    }
}

@-moz-keyframes ripple {
  100% {
      opacity: 0; 
        -moz-transform: scale(2.5);
        -webkit-transform: scale(2.5);
        transform: scale(2.5);
        border-radius: 90%;
    }
}

JavaScript

var parent, ink, d, x, y;
$(".btn").click(function(e){
	element = $(this);
	if(element.find(".drop").length === 0)
		element.prepend("<span class='drop'></span>");

	drop = element.find(".drop");
	drop.removeClass("animate");

	if(!drop.height() && !drop.width())
	{
		d = Math.max(element.outerWidth(), element.outerHeight());
		drop.css({height: d, width: d});
	}

	x = e.pageX - element.offset().left - drop.width()/2;
	y = e.pageY - element.offset().top - drop.height()/2;

	//set the position and add class .animate
	drop.css({top: y+'px', left: x+'px'}).addClass("animate");
});