nichollascarter / subjx

Drag/Resize/Rotate Javascript library
MIT License
211 stars 40 forks source link

mimic move for new elements #48

Open redgriffith opened 3 years ago

redgriffith commented 3 years ago

Hello,

I see that we can mimic move with this option each: { move: true, }

the problem is that it seems to work only with existing elements. -> When i add a new element on the scene and move it, mimic with others existing elements not working. We saw it on your example with thoses two yellow rectangle http://jsfiddle.net/nichollascarter/qgwzch0v/

My idea is to create a function like this -> if i move a draggable element (i can know that with your onmove function) then move all elements with class ".draggable" which have also specific class (for example ".mimic").

Add and remove the .mimic class will be easier for me, i can do it. ...But my real problem is how can i use your code in subjx.dev to call a mimic function ??

Thanks in advance !

nichollascarter commented 3 years ago

Hi @redgriffith

Did you see this example?

const observable = subjx.createObservable();
subjx('.draggable').drag({...}, observable);

const createDraggableAndSubscribe = e => {
    subjx(e.target).drag({...}, observable);
};

You should use external observable instance if you want to add new element.

redgriffith commented 3 years ago

Hello Thanks for you reply, i think it's what i searched for

Nevertheless i tried combinations on your example fiddle but don't succeed with yellow rectangle ?

i don't understand how to use it correctly ^^;

thanks