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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:21:39+00:00 2026-06-05T21:21:39+00:00

Below I have a function that animates a div ( container ) either to

  • 0

Below I have a function that animates a div (container) either to the left or the right depending on whether one variable (nextItem) is larger than the other (currentItemRel).

The problem I am having is using the distance variable in the .animate() function.

How can I pass this variable? Currently my JavaScript is breaking so any help would be appreciated.

Thankyou

var distance = (nextItem - currentItemRel) * 1260;

            if (nextItem > currentItemRel)
            {

                $('#container').animate({ left: -=distance }, 1200);

            } else if (nextItem < currentItemRel)
            {
                $('#container').animate({ left: +=distance }, 1200);
            };
  • 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-06-05T21:21:40+00:00Added an answer on June 5, 2026 at 9:21 pm

    the += and -= modifier for the jquery animate function, has to be parsed as a string.

    Check out this fiddle

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

Sidebar

Related Questions

I have an example function below that reads in a date as a string
I have a div.infotext with one paragraph inside. I animate the height of that
I have several Div's that appear and would like each one to have a
http://jsfiddle.net/AndyMP/nUhhf/1/ This is a simplified situation where I have a DIV that animates downwards
I have a row of images that are moving left or right with animate().
I have the below function that works a treat, but instead of clicking the
I have this Javascript below using jQuery that shows a div on a page
let say i have function like below function doSomethingNow(){ callSomethingInFutureNotExistNow(); } at the moment
I have template function compare defined as below. #include<iostream> using namespace std; template<typename T>
I have a function as below extern C int FuncTrace(const char *fmt, ...) {

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.