-
-
Save theredhead/dbf63ba437be72eae78a25e7889890b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container { | |
margin: 1em; | |
padding: 1em; | |
} | |
button { | |
position: relative; | |
border: none; | |
padding: 8px; | |
background-color: rgba(66, 100, 200, .9); | |
color: rgba(255, 255, 255, 1); | |
font-weight: bold; | |
overflow: hidden; | |
box-shadow: 0 1px 4px rgba(66, 100, 200, .5); | |
} | |
.ripple { | |
position: absolute; | |
background: rgba(255, 255, 255, .75); | |
border-radius: 50%; | |
transform: scale(0); | |
animation: rippleEffect .5s ease-in; | |
} | |
@keyframes rippleEffect { | |
to { | |
opacity: 0; | |
transform: scale(3); | |
} | |
100% { | |
opacity: 0; | |
transform: scale: (0); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<button>Hello, World!</button> | |
<button>Hello, World!</button> | |
<button>Hello, World!</button> | |
<button>Hello, World!</button> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(d) { | |
var startRipple = function(e) { | |
var circle = d.createElement('div'); | |
var diameter = Math.max(this.clientWidth, this.clientHeight); | |
circle.style.width = circle.style.height = diameter + 'px'; | |
circle.style.top = e.clientY - this.offsetTop - (diameter / 2) + 'px'; | |
circle.style.left = e.clientX - this.offsetLeft - (diameter / 2) + 'px'; | |
circle.classList.add('ripple'); | |
this.appendChild(circle); | |
setTimeout(function() { | |
circle.parentNode.removeChild(circle); | |
}, 500); | |
}; | |
var buttons = document.getElementsByTagName('button'); | |
for (var i = 0; i < buttons.length; i++) { | |
buttons[i].addEventListener('click', startRipple); | |
} | |
})(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment