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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:20:25+00:00 2026-05-25T10:20:25+00:00

I have a list of items each with heavy content. When I apply jQuery

  • 0

I have a list of items each with heavy content. When I apply jQuery sortable, what I wanted to achieve is this, when an item is dragged away and starts sorting, all the item contents will be hidden automatically.

From all my testtings, jQuery doesn’t accommodate such changes very well, for example, if I do the following,

$("#sortable").sortable({
    start: function(event, ui) {
        $(".hidden").addClass("hide");      
    }
});

jQuery can’t automatically figure out the sizes of hidden items and the sorting will be a mess.

So I solved it using an indirection, I firstly check mousedown, mouseup and mousemove event, and once dragging is detected (say when mousedown/mousemove for more than 50ms), I’ll hide the items immediately.

And in jQuery, I used some delay to start sorting.

var mouse_down = false;
var mouse_down_time;
var content_hidden;
$(".drag-handle").bind("mousedown", function(e) {
    mouse_down = true;
    mouse_down_time = e.timeStamp;
    $(".drag-handle").bind("mousemove", function(e) {
        if (mouse_down && !content_hidden) {
            if (e.timeStamp - mouse_down_time > 10) {
                $(".hidden").addClass("hide");
                content_hidden = true;
            }
        }
    });
}).bind("mouseup", function(e){
    $(".drag-handle").unbind("mousemove");
    mouse_down = false;
    if (content_hidden) {
        $(".hidden").removeClass("hide");
        content_hidden = false;
    }
});

$("#sortable").sortable({
    delay:100,
    stop: function(event, ui) {
        if (content_hidden) {
            $(".hidden").removeClass("hide");
            $(".drag-handle").unbind("mousemove");
            content_hidden = false;
        }
    }
});

So jQuery will start sorting after item contents are hidden.

Everything works fine except the helper offset. The helper offset seems to bump up for exactly the amount of spaces occupied by the all the item contents above the dragged item (which are hidden now during dragging).

So my question is,

is there a way to dynamically calculate all the item heights before and after hidden, and set the helper offset accordingly?

Thanks.

  • 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-25T10:20:26+00:00Added an answer on May 25, 2026 at 10:20 am

    Well, problem solved.

    What I did is dynamically calculate all the items height above the dragged item (before and after hiding contents), and then set the helper offset to the corresponding value by setting css:({‘top-margin’:offset_value+’px’})

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

Sidebar

Related Questions

I have a list of items, where each item is a simple class containing
I have a list of items. When I create the list each item has
Say I have a list of items from a database. Next to each item
Hopefully this is simple: I have a relatively long list where each list item
I have a list of items and each item has a Html.CheckBox. What is
I have a list of items and each item contains a list of sub
I have a list of items and each item has a checkbox attached to
I have a list if items and on each item I have button. When
My goal is to have a list of items each item has an image
I have a list of items that is refreshed daily where each item falls

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.