Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function PluginsSnappable() {
const containerSelector = '#Snappable .BlockLayout';
const containers = document.querySelectorAll(containerSelector);
if (containers.length === 0) {
return false;
}
const swappable = new Swappable(containers, {
mirror: {
appendTo: containerSelector,
constrainDimensions: true,
},
plugins: [Plugins.Snappable],
});
// --- Draggable events --- //
swappable.on('drag:start', (evt) => {
if (evt.originalSource.classList.contains('Block--typeStripes')) {
evt.cancel();
}
});
return swappable;
}
if (appendTo) {
options.appendTo = appendTo;
}
options = _.assign({}, options, {
delay,
sensors,
plugins,
});
if (this.ownInstance) {
switch (draggableType) {
case 'droppable':
this.draggableInstance = new Droppable(this.ownInstance, options);
break;
case 'swappable':
this.draggableInstance = new Swappable(this.ownInstance, options);
break;
case 'sortable':
this.draggableInstance = new Sortable(this.ownInstance, options);
break;
case 'draggable':
default:
this.draggableInstance = new Draggable(this.ownInstance, options);
break;
}
}
}
export default function GridLayout() {
const containerSelector = '#GridLayout .BlockLayout';
const containers = document.querySelectorAll(containerSelector);
if (containers.length === 0) {
return false;
}
const swappable = new Swappable(containers, {
draggable: '.Block--isDraggable',
mirror: {
appendTo: containerSelector,
constrainDimensions: true,
},
plugins: [Plugins.ResizeMirror],
});
return swappable;
}
export default function Flexbox() {
const containers = document.querySelectorAll('#Flexbox .BlockLayout');
if (containers.length === 0) {
return false;
}
const swappable = new Swappable(containers, {
draggable: '.Block--isDraggable',
mirror: {
constrainDimensions: true,
},
plugins: [Plugins.ResizeMirror],
});
return swappable;
}
export default function Floated() {
const containers = document.querySelectorAll('#Floated .BlockLayout');
if (containers.length === 0) {
return false;
}
const swappable = new Swappable(containers, {
draggable: '.Block--isDraggable',
mirror: {
constrainDimensions: true,
},
plugins: [Plugins.ResizeMirror],
});
return swappable;
}