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 Home() {
const containerSelector = '#Home .PlateWrapper';
const container = document.querySelector(containerSelector);
if (!container) {
return false;
}
const draggable = new Draggable(container, {
draggable: '.Plate',
});
const plates = new Plate(container);
// --- Draggable events --- //
draggable.on('drag:start', (evt) => {
plates.setThreshold();
plates.setInitialMousePosition(evt.sensorEvent);
});
draggable.on('drag:move', (evt) => {
// rAF seems to cause the animation to get stuck?
// requestAnimationFrame(() => {});
plates.dragWarp(evt.source, evt.sensorEvent);
});
export default function DragEvents() {
const toggleClass = 'PillSwitch--isOn';
const containers = document.querySelectorAll('#DragEvents .PillSwitch');
if (containers.length === 0) {
return false;
}
const draggable = new Draggable(containers, {
draggable: '.PillSwitchControl',
delay: 0,
});
let isToggled = false;
let initialMousePosition;
let containerRect;
let dragRect;
let dragThreshold;
let headings;
let headingText;
// --- Draggable events --- //
draggable.on('drag:start', (evt) => {
initialMousePosition = {
x: evt.sensorEvent.clientX,
options.handle = `.${handle}`;
}
if (classes) {
options.classes = classes;
}
if (appendTo) {
options.appendTo = appendTo;
}
options = Object.assign(options, {
delay,
sensors,
plugins,
});
if (this.ownInstance) {
this.draggableInstance = new Draggable(this.ownInstance, options);
if (draggableRef) {
draggableRef(this.draggableInstance);
}
}
}
});
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;
}
}
}