Created
July 1, 2013 14:59
-
-
Save scottsappen/5901590 to your computer and use it in GitHub Desktop.
Your mouse is a magician - add on to https://gist.github.com/scottsappen/5901573
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
I decided to make the text follow the mouse. | |
First, download JqueryUI and place it in your usual js location. This library gives you all kinds of nice stuff, like moving a <div> around a page that follows your mouse. | |
<script src="/js/vendor/jquery-ui.min.js"></script> | |
Here’s my <div> by the way, this is what I’ll be using. | |
<div id="forworldmapcomment" style="position:absolute;"></div> | |
In your $(document).ready(function() {}); function add this: | |
$("#forworldmap").mousemove(function(e){ | |
$("#forworldmapcomment").position({ | |
my: "bottom-20", | |
of: e, | |
collision: "fit" | |
}); | |
}); | |
That’s all there is to it, your <div> with id forworldmapcomment will follow the mouse around the screen. | |
I’ve positioned it 20 pixels above the event (mouse)’s position to avoid most conflicts. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment