Mouse over to change pokemon.
Created
November 8, 2011 00:11
-
-
Save alexandersimoes/1346617 to your computer and use it in GitHub Desktop.
Gotta Catch 'em All!
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
<!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