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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:08:37+00:00 2026-06-18T04:08:37+00:00

I have a small container and a large, variable-sized (the image is user-submitted) image

  • 0

I have a small container and a large, variable-sized (the image is user-submitted) image inside it that I want to be draggable. I’m using jQuery UI’s “draggable” feature for vertical dragging and it works well, but the only problem I’m having is that you can drag the image far up or down enough so that its edges show and you can see blank space above or below it in the container. I want it to work so that when, for example, the bottom edge of the image hits the bottom border of the container, you can’t drag it up any further.

I’m trying to use the

{ containment:[x1, y1, x2, y2] } 

option to make this work, and after a lot of trial and error I can calculate the correct values for differently-sized images, but I can’t figure out a functional relationship between the image size and what the containment values. Can anyone help me out, or point me in the right direction as to what kind of relationship image size and containment should have? The container is a fixed size of 360×240. Thanks so much.

JSfiddle: http://jsfiddle.net/Ey74c/ I don’t want any of the white space within the container to show – i.e. you can’t drag the image far enough up or down to let that happen. I tried setting containment: “parent” and it no longer scrolls?

  • 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-18T04:08:38+00:00Added an answer on June 18, 2026 at 4:08 am

    To solve this problem you should use: { containment:[x1, y1, x2, y2] }

    $("#container img").draggable({
        containment: [(parseInt($("#myImage").width()) - parseInt($("#container").width())) * -1, 
                      (parseInt($("#myImage").height()) - parseInt($("#container").height())) * -1, 0, 0]
    });
    

    jsFiddle

    x1 = – (img.width – container.width)

    y1 = – (img.height – container.height)

    x2 = 0

    y2 = 0

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

Sidebar

Related Questions

I have a small form that contains a jQuery UI dialog to ask for
I have one large view with a toolbar that allows a user to select
I have a small floating UIView, viewHover, which acts as a container to 2
I have a small issue with a method that should save the text contained
I have a small file test.txt contains a Long number inside while another piece
I have developed a small view that contains special char like 'é' and when
I have docbook generated HTML that contains small, fixed size images. All these images
I have used JQuery for a small animation work: a table #photos contains 9
Lately I have been needing to implement small classes that generate a bunch of
I have a Spring (3.1.) app that has a large app-context.xml file. There is

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.