-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OnTransfer event not fired with dragOrSwap plugin. #126
Comments
Same behaviour with the |
I found a work around by useing the dragAndDrop({
parent: mainGridContainer,
values: cardsData,
dragHandle: ".card-drag-handle",
draggingClass: "[&>.card]:-rotate-2 before:-rotate-2",
dropZoneClass: "blur-[2px] opacity-60",
draggable: (child) => child.id !== "no-drag",
onSort(data) {
console.log("main cards sorted", data);
},
onDragend: async ({ parent, draggedNode }) => {
if (parent.el === pinnedGridContainer.value) {
// pinning the card
const id = (draggedNode.data.value as Card).id;
const { data, error } = await togglePinCard(id, 1);
if (error.value) {
// reverse the grid transfer
interGridTransfer(draggedNode.data.value as Card, { pin: false });
}
if (data.value?.data) {
// update the pinned cards data
const index = pinnedCardsData.value.findIndex(
(card) => card.id === data.value?.data?.id
);
pinnedCardsData.value[index] = data.value?.data;
}
}
remapNodes(mainGridContainer.value!);
remapNodes(pinnedGridContainer.value!);
},
plugins: [dropOrSwap()],
group: "cards",
});
dragAndDrop<Card>({
parent: pinnedGridContainer,
values: pinnedCardsData,
dragHandle: ".card-drag-handle",
draggingClass: "[&>.card]:-rotate-2 before:-rotate-2",
dropZoneClass: "blur-[2px] opacity-60",
onSort(data) {
console.log("pinned cards sorted", data);
},
onDragend: async ({ draggedNode, parent }) => {
if (parent.el === mainGridContainer.value) {
// unpin the card
const id = (draggedNode.data.value as Card).id;
// transfer the card to the pinned grid
const { data, error } = await togglePinCard(id, 0);
if (error.value) {
// reverse the grid transfer
interGridTransfer(draggedNode.data.value as Card, { pin: true });
} else if (data.value?.data) {
// update the unpinned cards data
const index = cardsData.value.findIndex(
(card) => card.id === data.value?.data?.id
);
cardsData.value[index] = data.value?.data;
}
}
remapNodes(pinnedGridContainer.value!);
remapNodes(mainGridContainer.value!);
},
accepts: (target) => {
if (
target.el === pinnedGridContainer.value &&
target.data.enabledNodes.length < appConfig.pinnedCardsLimit
) {
return true;
}
return false;
},
plugins: [dropOrSwap()],
group: "cards",
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have the following setup. Two grids, one for normal cards and one for pinned cards. cards can be transferred between the two grids.
I am facing two issues.
1- When i use the
dragOrSwap
plugin theonTransfer
event is not fired and therefor the code to update the backend is not triggered.2- The reason i had to use
dragOrSwap
in the first-place. was because when i drag a card over between the two grids to transfer it when the user is not fast it inserts two cards instead of one.I am not sure how to fix any of the above two issues. I would appreciate any hints
The text was updated successfully, but these errors were encountered: