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

The Archive Base Latest Questions

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

I have two draggable elements on the same x axis. I want to reproduce

  • 0

I have two draggable elements on the same x axis. I want to reproduce a slider effect, I mean slider 1 can’t go after slider 2.

I don’t know how to do that. Can anyone help me?

I use jQuery and the draggable plugin from jQuery UI.

EDIT :

Code :
HTML :

<div id="chrono-bar">
<div id="slider-left" class="slider-left draggable obstacle"></div>
<div id="slider-right" class="slider-right draggable"></div>
<ul class="chrono-bar-ul block">
    <li class="chrono-bar-item">Janvier</li>
    <li class="chrono-bar-item">Février</li>
    <li class="chrono-bar-item">Mars</li>
    <li class="chrono-bar-item">Avril</li>
    <li class="chrono-bar-item">Mai</li>
    <li class="chrono-bar-item">Juin</li>
    <li class="chrono-bar-item">Juillet</li>
    <li class="chrono-bar-item">Aout</li>
    <li class="chrono-bar-item">Septembre</li>
    <li class="chrono-bar-item">Octobre</li>
    <li class="chrono-bar-item">Novembre</li>
    <li class="chrono-bar-item last">Décembre</li>
</ul>
<div class="chrono-bar-footer">
    <div class="line"></div>
</div>

Javascript :

<script>
$("#slider-left").draggable({ 
    axis: 'x', 
    containment: 'parent',
    'snap': '#slider-right', 
    collide: 'block',
    drag: function() {
        console.log($('#slider-left').offset().left);
    }
});
$("#slider-right").draggable({ axis: 'x', containment: 'parent','snap': '#slider-left' });

  • 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-24T18:07:16+00:00Added an answer on May 24, 2026 at 6:07 pm

    My solution was to change on each drag the containment area. I share my code with you :

    var left = $('#chrono-bar').offset().left;
    $("#slider-left").draggable({ 
        axis: 'x', 
        containment: [left,100,left+944-46,100],
        'snap': '#slider-right', 
        collide: 'block',
        drag: function() {
            $("#slider-right" ).draggable( "option", "containment", [$(this).position().left+left+46-5, 100, left+944-46, 1000] );
            autoWidth = $("#slider-right" ).position().left - $(this).position().left-46;
            $('#slider-middle-auto').css({width:autoWidth+'px', left: $(this).position().left + 46+'px'});
            $("#slider-left").css({'background-position':'0px -68px'});
        },
        stop:function(e) {
            autoWidth = $("#slider-right" ).position().left - $(this).position().left-46;
            $('#slider-middle-auto').css({width:autoWidth+'px', left: $(this).position().left + 46+'px'});
            $("#slider-left").css({'background-position':'0px 0px'});
            refreshListEvent(e);
        },
        grid : [77,77]
    });
    $("#slider-right").draggable({ 
        axis: 'x', 
        containment: 'parent',
        'snap': '#slider-left', 
        drag : function() {
            $("#slider-left" ).draggable( "option", "containment", [left-5, 100, $(this).position().left+left, 1000] );
            autoWidth = $(this).position().left - $("#slider-left" ).position().left - 46;
            $('#slider-middle-auto').css({width:autoWidth+'px', left: $("#slider-left" ).position().left + 46+'px'});
            $("#slider-right").css({'background-position':'0px -68px'});
        },
        stop:function(e) {
            autoWidth = $(this).position().left - $("#slider-left" ).position().left - 46;
            $('#slider-middle-auto').css({width:autoWidth+'px', left: $("#slider-left" ).position().left + 46+'px'});
            $("#slider-right").css({'background-position':'0px 0px'});
            refreshListEvent(e);
        },
        grid : [77,77]
    });
    
    $("#slider-right" ).draggable( "option", "containment", [$("#slider-left" ).position().left+left+46, 100, left+944-46, 1000] );
    $("#slider-left" ).draggable( "option", "containment", [left-5, 100, $("#slider-right" ).position().left+left, 1000] );
    
    autoWidth = $("#slider-right" ).position().left - $("#slider-left" ).position().left - 46;
    $('#slider-middle-auto').css({width:autoWidth+'px', left: $("#slider-left" ).position().left + 46+'px'});
    

    There is some bugs, but i think it’s a good start !

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

Sidebar

Related Questions

I have two set of draggable and two sets of dropable elements. What I
I have two li elements which are jQuery draggable. When I drag and drop
I have two container divs and want to drag and drop elements between them.
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two elements: <input a> <input b onclick=...> When b is clicked, I
I have two classes, and want to include a static instance of one class
I have two spreadsheets... when one gets modified in a certain way I want
I have two webapplication, one is a simple authenticationsite which can authenticate the logged
I have two divs: one draggable and one droppable <div id=draggable class=block runat=server> </div>
In my app I have some draggable sprite some in the same level, other

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.