Skip to content

Instantly share code, notes, and snippets.

@marcdhansen
Last active August 29, 2015 14:05
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 marcdhansen/fb9fef8b1d74ac9d9fbf to your computer and use it in GitHub Desktop.
Save marcdhansen/fb9fef8b1d74ac9d9fbf to your computer and use it in GitHub Desktop.
grapsing hand cursor

Example showing how to switch between an open and closed hand cursor during mouse up and down events.

Modified from http://jsfiddle.net/uZ377/21/ for use with d3.

<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
}
div{
height: 100px; border: solid 1px #ddd;
}
.open {
cursor: url(https://mail.google.com/mail/images/2/openhand.cur), default !important;
}
.closed {
cursor: url(https://mail.google.com/mail/images/2/closedhand.cur), default !important;
}
</style>
<body>
<div class="open">
Open Hand
</div>
<div class="closed">
Closed Hand
</div>
<div id="click" class="open">
Click Me
</div>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
<script>
d3.select("#click")
.on("mousedown", function() {
d3.select(this).classed({'open' : false, 'closed' : true});
})
.on("mouseup", function() {
d3.select(this).classed({'open' : true, 'closed' : false});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment