Skip to content

Instantly share code, notes, and snippets.

@hokaccha
Created June 24, 2015 01:25
Show Gist options
  • Save hokaccha/200d12c9b502a1e25ad0 to your computer and use it in GitHub Desktop.
Save hokaccha/200d12c9b502a1e25ad0 to your computer and use it in GitHub Desktop.
eNNzrv
<span class="blank-heart"></span>
var icon = document.querySelector('span');
icon.addEventListener('click', function() {
if (icon.classList.contains('heart')) {
icon.classList.remove('heart');
icon.classList.add('blank-heart');
}
else {
icon.classList.remove('blank-heart');
icon.classList.add('heart');
icon.classList.add('animation-start');
}
});
span {
-webkit-tap-highlight-color: rgba(0,0,0,0);
font-family: sans-serif;
cursor: pointer;
}
.blank-heart:before {
content: '♡';
font-size: 30px;
display: inline-block;
color: pink;
}
.heart:before {
content: '♥';
color: pink;
font-size: 30px;
display: inline-block;
outline: none;
}
.animation-start.heart:before {
-webkit-animation: heart 0.5s;
animation: heart 0.5s;
}
@-webkit-keyframes heart {
0% { -webkit-transform: scale(1) }
50% { -webkit-transform: scale(1.3) }
100% { -webkit-transform: scale(1) }
}
@keyframes heart {
0% { -webkit-transform: scale(1) }
50% { -webkit-transform: scale(1.3) }
100% { -webkit-transform: scale(1) }
}
@keyframes heart {
0% { transform: scale(1) }
50% { transform: scale(1.3) }
100% { transform: scale(1) }
}
@keyframes heart {
0% { transform: scale(1) }
50% { transform: scale(1.3) }
100% { transform: scale(1) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment