marcospont / agnostic-draggable

An agnostic set of libraries implementing draggable, droppable, sortable and resizable behaviors inspired by the jQuery UI implementation
MIT License
39 stars 7 forks source link

Droppable option accept function triggers every time position of the draggable is changed over it #15

Closed andreiciobanica closed 1 year ago

andreiciobanica commented 1 year ago

When you have:

const drag = new Draggable(document.querySelector('.square-2'), {
    helper: "clone",
    scroll: false,
    zIndex: 3,
});

const drop = new Droppable(document.querySelector(".action-button-use"), {
    accept: function(d: any){ console.log(d); },
})

every time you move the draggable div on droppable div it triggers the accept function.

marcospont commented 1 year ago

This is the expected behavior when the 'accept' option contains a function call.

The check needs to be applied every time, because the droppable component does not know what the function is doing so it cannot assume that it can be called only once or less frequently.