Trigger Event When Mouse Gets Near An Element – aura.js

aura.js is a lighweight jQuery plugin that enables to trigger an event when the mouse gets near (within) an html element.

Demo

Download

Trigger Event When Mouse Gets Near An Element aura js

Usage:

Be sure to have already included the jQuery javascript library and aura.js in your document. I suggest you include the 2 files at the bottom of your page to reduce the page load tim.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../dist/jquery.aura.js"></script>

Trigger a callback when the mouse gets within a 40 pixel box around <div id=”cake”/>:

$('#cake').aura(40, function () { alert('Remember your diet!'); });

You can also specify the box as if you were defining css padding (pixels only):

$('#cookies').aura('40px 30px 20px 10px', function () { alert("I'll just have one"); });

You can also specify the callback promise style:

$('#pie').aura(15).then(function () { alert('3.14159265359'); });

Leave a Reply