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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:13:43+00:00 2026-06-13T05:13:43+00:00

when dragging an element I am doing some calculation and when a certain critaria

  • 0

when dragging an element I am doing some calculation and when a certain critaria is matched I’d like the dragging to pause.

I don’t want trigging a mouseup event, just pause.

I have a perfect example set on this JS FIDDLE

Please see a container and a list of rectangles.
What I would like to achieve is somewhat the opposite as containment…

If I would be to set the containment to be .draggable_wrapper, than my UL list would be constrained inside…I DON’T WANT THAT

What I’d like is that when I drag the list, if the list position is more than zero (>0) TO pause dragging to the right and allow dragging only to the left (so to the negative position)…

I don’t want first LI’s left border to ever get to the right of the container left border…

and in the other side the exact same thing…. when draggin to the left… I want to stop when the 8. li’s right border crossing the container’s right border (this happens in the example where position is < than -55px;

so to make it more readable

$(....).draggable({
....
drag: function(){
var p_left = $(this).position().left;

if(left > 0) stop_dragging_right, allow only left;
if(left < -55px) sto_dragging_left, allow_only_right;

});

How can I do that? similar is done when constraining

  • 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-13T05:13:44+00:00Added an answer on June 13, 2026 at 5:13 am

    You can obtain the coordinates of your wrapper element with offset() and provide your own containment box by passing an array in the containment option:

    var wrapperOffset = $(".draggable_wrapper").offset();
    $('.draggable_wrapper ul').draggable({
        distance: 3,
        axis: "x",
        revert: false,
        scroll: false,
        containment: [
            wrapperOffset.left - 55,
            wrapperOffset.top,
            wrapperOffset.left,
            wrapperOffset.top
        ],
        drag: function(e) {
            $('#posx').val($(this).position().left);
        }
    });
    

    You will find an updated fiddle here.

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

Sidebar

Related Questions

In GWT, how do I get the mouseUp events when dragging an element? I'd
I want to make something like navigation bar that can move whole element, without
I am doing some sort of drawing software in WPF, and I have certain
I want to change the attributes of a draggable element during dragging (font color,
I'm doing some Drag and Drop operations, and I want to use a visual
I'm looking a way to binding the snap event. When I'm dragging an element
I'm dragging from a TileList to a custom component. I want to know what
how would you prevent dragging for some items of your List or DataGrid? Let's
When finish dragging a HTML5 draggable element, the element will revert back to its
I'm making a drag and drop application and when I'm dragging an element inside

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.