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 3966048
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:32:51+00:00 2026-05-20T03:32:51+00:00

The picture is pretty much explanatory by itself. The div behind contains a bunch

  • 0

The picture is pretty much explanatory by itself. The div “behind” contains a bunch of little square photos that I want to animate smoothly. I’m really not good with jQuery animations, could anyone help me out with this?

(Window is fixed, pictures move “inside” it, animating forever since the page load)

enter image description here

  • 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-20T03:32:52+00:00Added an answer on May 20, 2026 at 3:32 am

    I’m a fan of SIN/COS functions, so let me share with you my shot at this problem.

    The idea is to have a function that runs forever, and as soon as possible so that the animation is smooth. I use a sin/cos functions to determine the new x (left) and y (top) coordenates of the div, and I have a series of parameters that allow the configuration of the speed and range of the animation.

    Just paste this into an HTML file and test it in your browser.

    <html>
        <head>
            <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
        </head>
        <body>
            <div id="stuff" style="background: red; width: 200px; height: 200px; margin: auto; position: relative;">
            a b c<br />
            d e f<br />
            g h i<br />
            j k l<br />
            </div>
            <script>
                var start = new Date();
                var x_speed = 0.001, // bigger ---> faster
                    y_speed = 0.01, // bigger ---> faster
                    x_multiplier = 300, // how far away I can go on the X axis
                    y_multiplier = 20, // how far away I can go on the Y axis
                    x_offset = 0,
                    y_offset = 0;
    
                function animate() {
    
                    var now = new Date();
                    var elapsed_time = now - start;
    
                    var x = Math.sin((elapsed_time)*x_speed) * x_multiplier + x_offset;
                    var y = Math.cos((elapsed_time)*y_speed) * y_multiplier + y_offset;
    
    
                    $("#stuff").css({
                        left : x,
                        top : y
                    });
    
                    setTimeout(animate, 0);
                }
    
                setTimeout(animate, 76);
    
            </script>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly, let me say that I've been on this issue for pretty much 2
This is pretty much what I want to do.... So, the user is browsing
The picture shows these little gaps. The big, blue containers between the gaps are
The title pretty much says it all. I'm trying to use jQuery's ability (hoping
It was pretty easy to get the Contact picture when querying the People.CONTENT_URI ,
The question pretty much says it all, I've tried setting the backcolour to transparent
This code pretty much just shows a a table with 16 cells (4 columns
Edit: Just wanted to make the question I have more clear. I pretty much
A frequently answered question, I'm afraid but I am pretty much in the dark
I'm very much a Tomcat newbie, so I'm guessing that the answer to this

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.