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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:32:07+00:00 2026-05-24T13:32:07+00:00

My page has several items (divs) that are draggable and resizable. My code for

  • 0

My page has several items (divs) that are draggable and resizable.
My code for doing this is given below:

part.draggable(
                     {
                                containment: 'parent',
                                drag: function(event, ui){
                                partIsDragging = true
                                part.prev().css('top', ui.position.top - 20 ).css('left', ui.position.left )
                                part.prev().show()
                           },
                                stop: function(event, ui) {
                                         partIsDragging = false
                            }
                              }).resizable({
                                 containment: 'parent',
                                 handles: 'ne, se, sw, nw,n,w,e,s',
                                 stop: function() {
                                            }                                        
                              });

The html structure for these is the following:

<body>
<div id="wrapper">
    <div class="draggableItem"></div>
    <div class="draggableItem"></div>
    <div class="draggableItem"></div>
    <div class="draggableItem"></div>
</div>
</body>

In my css files i have set body height: 100% and wrapper height: 100%. Width is always fixed for wrapper, width: 950px. I want my div to expand in height when the draggableItem reaches the bottom of the wrapper. Right now when the page is loaded, it has the height as big as the resolution allows it but in case I have more items in the wrapper then everything becomes cluttered and I would like when dragging an item to somehow expand the wrapper in height dynamically. This should happen only if I hit the bottom border.

PS: I am using jQuery and jQuery-ui.

  • 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-24T13:32:09+00:00Added an answer on May 24, 2026 at 1:32 pm

    I may have a solution. First off, I replaced part with '.draggableItem' and this where appropriate. Please tell me if that breaks the code in some critical way. In addition, I removed part.prev().css('top', ui.position.top - 20 ).css('left', ui.position.left ) in the code below.

    function adjustWrapperHeight(movingObject)
    {
        var objectBottomPosition = $(movingObject).offset().top+$(movingObject).height()
        var wrapperBottomPosition = $("#wrapper").offset().top+$("#wrapper").height()
        if(wrapperBottomPosition-objectBottomPosition<distanceBuffer)
        {
            $("#wrapper").height($("#wrapper").height()+distanceBuffer+1)
        }
    }
    
    var distanceBuffer = 20;
    $('.draggableItem').draggable(
            {
                containment: 'parent',
                drag: function(event, ui)
                {
                    partIsDragging = true
                    adjustWrapperHeight(this)
                },
                stop: function(event, ui)
                {
                    partIsDragging = false
                }
            }).resizable(
            {
                 handles: 'ne, se, sw, nw,n,w,e,s',
                 resize: function(event, ui)
                 {
                    adjustWrapperHeight(this)
                    var objectRightPosition = $(this).offset().left+$(this).width()
                    var wrapperRightPosition = $("#wrapper").offset().left+$("#wrapper").width()
                    if(wrapperRightPosition<=objectRightPosition)
                    {
                        $(this).width(ui.originalSize.width)
                        var containmentLeftPosition = wrapperRightPosition-$(this).width()
                        $(this).offset({top:$(this).offset().top,left:containmentLeftPosition})
                    }
                 }                                    
             })
            })
    

    The function adjustWrapperHeight(movingObject) adjusts div#wrapper‘s height depending on a movingObject‘s bottom position. That is, when movingObject “pushes up” against div#wrapper‘s borders, it adjusts div#wrapper‘s height.

    I had to use a hack for resizable. The containment: 'parent' for resizable (but not draggable) sets the containment to the container’s ORIGINAL height or so it seems. That means as the height of div#wrapper dynamically changes, the constraint set by containment: 'parent' does not dynamically change. To fix this, I removed containment: 'parent' and indeed the entire containment and ensured that div#wrapper‘s right containment isn’t broken within the resize event. Note that you should probably do this with div#wrapper‘s left containment as well.

    Please tell me if this was helpful. Thank you.

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

Sidebar

Related Questions

I have several ReorderLists on a page. Each list has items added to it
I have a page that has several ajax submission forms. Each form has a
I have a login page that has several textboxes on the page, one of
I have a complex page that has several user controls like galleries, maps, ads
Page has menu items that would replace a 'div id=foo_(current menu item)' with 'div
I have a loginview in my webform that has several Items. I want to
I have a page which has several <canvas> elements. I am passing the canvas
My site has several listing pages and on each page, I'd like to enable
The page has a container div which holds multiple content divs. Each content div
This Wikipedia page has an extensive list of hashing methods As you can see,

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.