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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:29:27+00:00 2026-06-02T19:29:27+00:00

I have a draggable image within a div functioning. However I would like to

  • 0

I have a draggable image within a div functioning. However I would like to make it so if while the user has the mouse down and is dragging the element / div, when the mouse goes outside of the div when its down or its bounds it will no longer be draggable. The dragging is enabled when a button is pressed on the control, which functions correctly. I just would like to be able to stop dragging when the mouse goes out of bounds of a specific div / element.

This is part of a composite control so when the page loads, the scripts are registered with the page.

jQuery.fn.Draggable = function (button) {

    if (button.value == "Off") {

        button.value = "On";
        this.draggable({ cursor: "hand" });


    } else {
        button.value = "Off";
        this.draggable("destroy");
    }
}

jQuery.fn.Drag = function (button) {
    this.Draggable(button);
}

Thanks in advance.

Edit:

I have used containment already but I dont want the image fixed inside the div. I want the image to be able to go out of bounds, but when the mouse goes out of bounds it will stop dragging.

So When the mouse goes outside the div box, dragging stops. I dont want to contain the object inside the div. I have already tinkered around with it.

  • 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-02T19:29:28+00:00Added an answer on June 2, 2026 at 7:29 pm

    Can you register mouseenter/mouseleave events on the containing div that enables/disables the dragging functionality?

    $('div#container').mouseenter(function(event) {
        // enable dragging
    
    }).mouseleave(function(event) {
        // disable dragging
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an image inside a div, like so: <div><img src= class=draggable></div> It's a
I have a draggable image within a div. I can click on the image
I have some particular need to clone an element (image) and be draggable inside
I have a table of draggable rows. I'm subclassing NSImageCell to render an image,
I have an element inside a div that is draggable jquery ui. And I
I have a TableLayout within ScrollView with a background image. The problem I face
So I have a contenteditable=true div, of which there are images and text within
I have something like this: <div class=wrapper> <div class=drag object1>Example1</div> <div class=drag object1>Example1</div> <div
I have a form in which user inputs its data along with its image.
I've been developing a image manipulation script which has a background and user can

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.