desandro / draggabilly

:point_down: Make that shiz draggable
https://draggabilly.desandro.com
MIT License
3.86k stars 387 forks source link

Binding two elements #179

Closed OlegShklyarov closed 6 years ago

OlegShklyarov commented 6 years ago

Hello, thank you for your awesome script! I have a question - how to move two separate objects simultaneously? Is there an option to bind several elements?


<h1 class="drag">Text1</h1>
<h1 class="bind">Text1</h1>
desandro commented 6 years ago

Hello! Thanks for your question. The best way to bind two elements to move together is to add them to a parent element, use that as the dragging element, but set the two elements as handles.

See https://draggabilly.desandro.com/#handle

<div class="draggie">
  <h1>Text1</h1>
  <h1>Text2</h1>
</div>
new Draggabilly( '.draggie', {
  handle: 'h1',
};