Skip to content

Instantly share code, notes, and snippets.

@alexandersimoes
Created November 8, 2011 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexandersimoes/1346617 to your computer and use it in GitHub Desktop.
Save alexandersimoes/1346617 to your computer and use it in GitHub Desktop.
Gotta Catch 'em All!

Mouse over to change pokemon.

<!DOCTYPE html>
<html>
<head>
<style>
body {
font: 10px sans-serif;
}
.img_container{
background: url('http://fc08.deviantart.net/fs50/f/2009/295/7/6/Platinum_Pokemon_Sprites_by_Emporer15.png');
background-position: 0px 0px;
height: 80px;
opacity: 1;
width: 80px;
}
</style>
</head>
<body>
<div class="img_container"></div>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script>
var counter = 0;
d3.select(".img_container").on("mouseover", function(){
counter -= 40;
d3.select(this).transition().duration(500)
.style("background-position", counter+"px 0")
.style("opacity", 0)
.each("end", function(d, i){
counter -= 40;
d3.select(this)
.style("background-position", counter+"px 0")
.transition().duration(500)
.style("opacity", 1)
})
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment