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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:20:28+00:00 2026-05-20T16:20:28+00:00

what I am trying to do is have an large image contained within a

  • 0

what I am trying to do is have an large image contained within a smaller div that the user can drag around within the containing div (easy enough)… similar to http://oneblackbear.com/draggable/index.html but I want to prevent users from dragging it any further then the container boundary. With the above example the user can drag the image completely outside of the containing div… I want to prevent the user from ever dragging the image outside of the parent div at all.

I have tried using jQuery UI draggable but the problem is if I use the constraint option as soon as you drag the image it locks to the bottom right and is no longer draggable because the child element is larger then the parent constraint. I am not sure if the ui draggable constraint is only intended for smaller objects then the parent container.

Does anyone have any ideas how do do with? preferably with jQuery Draggable?

  • 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-20T16:20:28+00:00Added an answer on May 20, 2026 at 4:20 pm
    var productHeadOffset = jQuery('#productHead').offset();
    var productHeadHeight = jQuery('#productHead').height();
    var productHeadWidth = jQuery('#productHead').width();
    var productHeadImageHeight = jQuery('.productHeadImage').height();
    
    var right = productHeadOffset.left;
    var bottom = productHeadOffset.top;
    
    var left = (img.width > productHeadWidth) ? (productHeadWidth + productHeadOffset.left) - img.width : 0;
    var top = (img.height > productHeadImageHeight) ? (productHeadHeight + productHeadOffset.left) - img.height : 0;
    
    jQuery('.productHeadImage').draggable({ containment: [left, top, right, bottom] });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a draggeable image contained within a box. You can zoom in and
I am trying to have one one layer, and center images within. I.E., if
I am trying to have a table header, in a seperate div stay in
I am trying to customize this script so that instead of a user's recent
I have a Camera class that produces very large images at a high FPS
I'm trying to load an extremely large image (14473x25684), but I'm hitting into a
I have a very large array of floating point image data: In[25]:= Dimensions[daylightImgd] Out[25]=
I have a layered div component which displays a successive series of large kb
hey guys, I have a large image, and then i'm extracting a portion of
I am trying to have a logout page where is displays a messages and

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.