I think this can be done by simulating the same thing done by Microsoft word.
They allow the elements to be dragged together if they are grouped together.
So what you need to do, is as soon as a sequence line comes in contact of a line for a class, you need to make a virtual grouping of the two and then drag logic should take care of the grouped elements being dragged together.
Let me know if this was helpful