Is it possible to link two jquery.ui draggables together?

前端 未结 5 1761
生来不讨喜
生来不讨喜 2020-12-18 05:07

I have two jquery.ui draggables. I am constraining their movement to the y-axis. If one is dragged to a certain y-position, I want the other to automatically move to the s

5条回答
  •  盖世英雄少女心
    2020-12-18 05:55

    I haven't done this before, but I suggest using the drag event to adjust the position of the respective other element:

    $('.selector').draggable({
        ...,
        drag: function(event, ui) {
    
        },
        ...
    });
    

    The ui object will contain information (in the property ui.offset) you can use to manually reposition the other element.

提交回复
热议问题