You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 1, 2026. It is now read-only.
Is it possible to cancel or delay the swappable swap event?
I'd like to implement swapping, doing an ajax call, depending on the result, success -> continue with swapped, failure, revert the swapping or rather not let it continue. For now event.cancel(); only seems to work with a synchronous call.
functiondelay(t,val){returnnewPromise(resolve=>setTimeout(resolve,t,val));}constcontainers=document.querySelectorAll('#container');if(containers.length===0){returnfalse;}constswappable=newDraggable.Swappable(containers,{draggable: '.Block--isDraggable',mirror: {constrainDimensions: true,},plugins: [Draggable.Plugins.ResizeMirror],});swappable.on('swappable:swap',async(e)=>{awaitdelay(1000);e.cancel();// Does not work anymoreconsole.log('Swap');});
Is it possible to cancel or delay the swappable swap event?
I'd like to implement swapping, doing an ajax call, depending on the result, success -> continue with swapped, failure, revert the swapping or rather not let it continue. For now event.cancel(); only seems to work with a synchronous call.