Created
March 21, 2016 07:59
-
-
Save hayashikun/a3473c70056d76bbd17a 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
<style> | |
#heart { | |
width: 280px; | |
height: 280px; | |
background-image: url(http://cdn-ak.f.st-hatena.com/images/fotolife/h/hayashikunsan/20160321/20160321164813.png); | |
background-position: left; | |
} | |
</style> | |
<div id="heart"></div> | |
<script> | |
document.getElementById("heart").addEventListener("click", function(el) { | |
var offset = 280 * 57; | |
var tm = setInterval(function() { | |
if (offset == 0) { | |
clearTimeout(tm) | |
} else { | |
el.target.style.backgroundPosition = offset + "px 50%"; | |
} | |
offset -= 280; | |
}, 50); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment