After my post on the release of jQuery 1.2, over lunch, I thought I would have some fun and try to make a jQuery plugin that takes absolutely positioned elements and causes them to vibrate upon mouse over. It's not all that well written, and it only works with absolutely positioned elements because I am not yet smart enough to figure out how to move relatively positioned elements. I know it's possible to do, since people do it for drag-n-drop, but I'm just not there yet.
So anyway, don't take this as any reference on how to write jQuery plugins - this was just for fun.
See vibrate() plugin in action (SAFE FOR WORK!!)
Here is the code for that page:
Launch code in new window » Download code as text file »
I've never done a jQuery plugin that has any sort of timed events; all of my plugins are one-off type features. I have no idea how you would go about doing this properly, so I just took a stab at it. I'd love to see how the Animation features work as those must have really clean timeouts and intervals and all that goodness.
Download Code Snippet ZIP File
Comments (9) | Post Comment | Ask Ben | Permalink | Other Searches | Print Page
Needs a nice .wav file to make it complete. :)
Posted by Jim Priest on Sep 12, 2007 at 3:54 PM
And you thought you were getting on search engines for odd keywords before. Just imagine what you'll get now!
"Where's my huge ass vibrator?!?!?"
LOL
Posted by Dustin on Sep 12, 2007 at 4:04 PM
Ha ha ha ha :)
Posted by Ben Nadel on Sep 12, 2007 at 4:19 PM
Thanksfor good script!
Posted by Trap on Sep 12, 2007 at 4:23 PM
@Trap,
I'm not sure how "good" it is :) I very rarely used time-events, and certainly, this is the first time I have ever even tried to do that within the context of a jQuery plugin. This was just a stab in the dark.
Posted by Ben Nadel on Sep 12, 2007 at 4:29 PM
Nice snippet. I can see a few uses for something like that in menu bars. Have you ever taken a look at Mootools? It has by far the best fx engine of any of the JS frameworks in my oppinion. Using Motools you could probably do something like that with 10% of the code.
Posted by David Hopkins on Sep 14, 2007 at 6:30 AM
Hi Ben Thanks for exploring and giving us Jquery script. I will utilize it in future work.
Posted by Creativ Era's on Dec 14, 2007 at 7:00 AM
Can't think of any practical uses for this - but it's still pretty cool anyway :) Now gonna see if I can understand this code.
Posted by Bill on Jan 16, 2008 at 8:01 PM
Well done, this code has helped me understand jQuery. I get it now, thank you so much, I had struggled for such a long time and now I will be able to use it.
Posted by Marcus on Feb 13, 2008 at 12:08 PM