Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4627158
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:31:36+00:00 2026-05-22T03:31:36+00:00

I’ve been sick for the past week and terribly bored, so I decided to

  • 0

I’ve been sick for the past week and terribly bored, so I decided to teach myself a bit more about writing jQuery plugins. I threw this one together in about half an hour and it emulates the “wiggle” effect when you press and hold down on a particular icon within an i(Phone|Pad|Pod Touch). To get it to start “wiggling” was easy enough, I just used CSS3 transitions.

http://area51.thedrunkenepic.com/wiggle/

However, to get the icons to STOP wiggling has proven to be a bit more difficult. I’m fairly new to creating jQuery plugins, so I’m not 100% clear on how to save the state of collected objects and then modify said state later on by, say, a callback or event.

So, I wound up creating an array which is used to collect all matched objects. I then use this array to maintain, more or less, the state of the objects which have the wiggle effect applied.

Even though it works, it seems overly inefficient which leads me to believe there is a better, perhaps intrinsic (within jQuery), way of getting this done.

Could someone take a look at this simple plugin and tell me what, if anything, I can do? I’m not asking for someone to improve my code. Perhaps a working example out in the real world or some solid documentation will suffice.

Thank you so much! 🙂

Plugin Source: http://area51.thedrunkenepic.com/wiggle/wiggle.jquery.js

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:31:37+00:00Added an answer on May 22, 2026 at 3:31 am

    You could store the setTimeout result in each object, like so:

    object.timeout = setTimeout(function(){
    methods.rotate(object, step+1);
    }, options.delay);
    

    Then in your stop function, call clearTimeout on it, like so:

    clearTimeout(object.timeout);
    

    The full plugin incorporating these changes is as follows:

    (function($){
    var rotatingObjectCollection = [];
    
    $.fn.wiggle = function(method, options) {
        options = $.extend({
            rotateDegrees: ['1','2','1','0','-1','-2','-1','0'],
            delay: 35
        }, options);
    
        var methods = {
            rotate: function(object, step){
                if(step === undefined) {
                    step = Math.floor(Math.random()*options.rotateDegrees.length);
                }
    
                var degree = options.rotateDegrees[step];
                $(object).css({
                    '-webkit-transform': 'rotate('+degree+'deg)',
                    '-moz-transform': 'rotate('+degree+'deg)'
                });
    
                if(step == (options.rotateDegrees.length - 1)) {
                    step = 0;
                }
    
                object.timeout = setTimeout(function(){
                    methods.rotate(object, step+1);
                }, options.delay);
            },
            stop: function(object) {
                $(object).css({
                    '-webkit-transform': 'rotate(0deg)',
                    '-moz-transform': 'rotate(0deg)'
                });
    
                clearTimeout(object.timeout);
                object.timeout = null;
            }
        };
    
        this.each(function() {
            if((method == 'start' || method === undefined) && !this.timeout) {
                methods.rotate(this);
            } else if (method == 'stop') {
                methods.stop(this);
            }
        });
        return;
    }
    })(jQuery);
    

    I don’t know if it’s good practice to store custom data inside the objects like this, but hey, it works 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I am writing an app with both english and french support. The app requests
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.