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

  • Home
  • SEARCH
  • 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 8904549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:09:40+00:00 2026-06-15T02:09:40+00:00

The code that follows refers to a block element that is serving as a

  • 0

The code that follows refers to a block element that is serving as a handle (this). This element is draggable through the jQuery UI. What I’m trying to do is determine the position the handle was dropped and depending on the range “category” it’s dropped in, I animate it to a point on the screen. The code works I just feel like I’m repeating myself but I don’t know how to sum this up.

         stop: function( event, ui ) {

            var left = ui.position.left,

                position = "";

            if (left >= 0 && left <= 80) {
                $(this).animate({left: 20}, 200);
                position = 1;
            }

            if (left >= 81 && left <= 198) {
                $(this).animate({left: 137}, 200);
                position = 2;
            }

            if (left >= 199 && left <= 315) {
                $(this).animate({left: 254}, 200);
                position = 3;
            }

            if (left >= 316 && left <= 430) {
                $(this).animate({left: 371}, 200);
                position = 4;
            }

            if (left >= 431 && left <= 548) {
                $(this).animate({left: 488}, 200);
                position = 5;
            }

            if (left >= 549) {
                $(this).animate({left: 605}, 200);
                position = 6;
            }

            $(content).children().fadeOut(300, "linear");
            $(content).children(':nth-child('+ position +')').delay(299).fadeIn(600, "linear");
        }
  • 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-15T02:09:41+00:00Added an answer on June 15, 2026 at 2:09 am
    //maybe something like this?
    
    stop: function( event, ui ) {
    
        var left = ui.position.left, position = [];
    
        if (left >= 0 && left <= 80)
            position = [20, 1];
    
        if (left >= 81 && left <= 198)
            position = [137, 2];
    
        if (left >= 199 && left <= 315)
            position = [254, 3];
    
        if (left >= 316 && left <= 430)
            position = [371, 4];
    
        if (left >= 431 && left <= 548)
            position = [488, 5];
    
        if (left >= 549)
            position = [605, 6];
    
        // OR
        /*
         var position = ((left >= 0 && left <= 80) ? [20, 1] :
         ((left >= 81 && left <= 198) ? [137, 1] :
         ((left >= 199 && left <= 315) ? [254, 3] :
         ((left >= 316 && left <= 430) ? [371, 4] :
         ((left >= 431 && left <= 548) ? [488, 5] :
         ((left >= 549) ? [605, 6] : [] ) ) ) ) ) );
         */
        if (position.length) {
            $(this).animate({
                left : position[0]
            }, 200);
            $(content).children().fadeOut(300, "linear", function() {
                $(content).children(':nth-child(' + position[1] + ')').delay(299).fadeIn(600, "linear");
            });
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code that I have is as follows: <!DOCTYPE html> <html> <head> <script src=javascript/jquery.js
I have code that follows this structure: class someClass { private static $pay =
We have a lot of data layer code that follows this very general pattern:
My code that I tried is as follows: var dataO = new Object(); dataO.numberId
A minimal code that reproduces the problem is as follows: <div class=cell> <input type=text
I have php code that puts some values into an Array as follows: $hunter=addslashes($MessageArray[1]);
I have a section of code that can be summarised as follows; void MyFunc()
I've come across code that looks like this: NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:1024
I have code that looks like follows: public interface BaseDAO{ // marker interface }
I am referencing JavaScript as follows on an HTML page: <script type=text/javascript src=http://code.jquery.com/jquery-1.6.1.min.js></script> <script

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.