-
Notifications
You must be signed in to change notification settings - Fork 108
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
Please make isItemsDragDisabled exported #617
Comments
Can you describe your usecase? Maybe I can come up with a solution that
doesn't require a new feature
…On Sat, Nov 30, 2024, 09:27 derheld42 ***@***.***> wrote:
With the updated draggable handle, I've found a use case where I'd like to
be able to subscribe to isItemsDragDisabled.
—
Reply to this email directly, view it on GitHub
<#617>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE4OZC2KY3EKH5U53GP6LAT2DDS45AVCNFSM6AAAAABSX2OEGKVHI2DSMVQWIX3LMV43ASLTON2WKOZSG4YDMMRWHE4DSMY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Totally open to other approaches -- this was me just trying to make things work :) In my local node_modules, I patched svelte-dnd-action with this to enable
Then in my client code, I was able to subscribe to dragging events with:
|
I mean, you decide whether the list is disabled or not in your code. Why do
you need the lib to tell you something your app already knows/ controls?
What am I missing?
…On Sat, Nov 30, 2024, 12:28 derheld42 ***@***.***> wrote:
Totally open to other approaches -- this was me just trying to make things
work :)
I wanted to track when dragging was happening in a state or a store. I
used that to pause updates that were happening to the list that's being
changed in the dragging.
In my local node_modules, I patched svelte-dnd-action with this to enable
file=node_modules/svelte-dnd-action/dist/index.mjs
patched="dndzone, isItemsDragDisabled, dragHandle"
unpatched="dndzone, dragHandle"
if ! grep "$patched" $file > /dev/null 2>&1; then
echo Patching $file
cp -v $file $file.orig
sed -i "s/$unpatched/$patched/" $file
else
echo $file already patched.
fi
file=node_modules/svelte-dnd-action/dist/index.d.ts
patched="export let isItemsDragDisabled: { subscribe: (cb : (arg: boolean) => void) => void };"
if ! grep "$patched" $file > /dev/null 2>&1; then
echo Patching $file
cp -v $file $file.orig
echo $patched >> $file
else
echo $file already patched.
fi
Then in my client code, I was able to subscribe to dragging events with:
import {
type DndEvent,
dragHandleZone,
dragHandle,
isItemsDragDisabled,
} from 'svelte-dnd-action';
...
isItemsDragDisabled.subscribe((disabled: boolean) => {
if (!disabled) {
g.itemsAddRemoveMutex++;
}
//console.log('isItemsDragDisabled:', disabled, g.itemsAddRemoveMutex);
});
—
Reply to this email directly, view it on GitHub
<#617 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE4OZC4Y7FTO6FWOHTMPMZL2DEICVAVCNFSM6AAAAABSX2OEGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMBYG43TKMJXGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
The use case is that the items are draggable and when they start being drug, I want a callback to fire so I can do some logic. I tried adding onmousedown and ontouchstart to the drag handle div, but it appears like the DragHandle action overrides them. When I removed the draghandle action, my onmousedown/ontouchstart callbacks were firing. After staring at the svelte-dnd-action code, I figured I'd try to subscribe to the isItemsDragDisabled store and it worked well --- after it was exported. |
why not do it in the "consider" handler when the trigger is DRAG_STARTED
(and turn it off on finalize)?
…On Sat, Nov 30, 2024 at 12:39 PM derheld42 ***@***.***> wrote:
The use case is that the items are draggable and when they start being
drug, I want a callback to fire so I can do some logic.
I tried adding onmousedown and ontouchstart to the drag handle div, but it
appears like the DragHandle action overrides them. When I removed the
draghandle action, my onmousedown/ontouchstart callbacks were firing. After
staring at the svelte-dnd-action code, I figured I'd try to subscribe to
the isItemsDragDisabled store and it worked well --- after it was exported.
—
Reply to this email directly, view it on GitHub
<#617 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE4OZC3JZDGWHCX3VWFDZN32DEJMLAVCNFSM6AAAAABSX2OEGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMBYG43TQNJUGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I think I tried that and the thought consider required a mouse move or thumb move before onconsider was called. If I’m wrong I’ll have to try that again. |
you can make a simple REPL if you run into trouble and i'll help you to
get it working.
…On Sat, Nov 30, 2024 at 4:43 PM derheld42 ***@***.***> wrote:
I think I tried that and the thought consider required a mouse move or
thumb move before onconsider was called. If I’m wrong I’ll have to try that
again.
—
Reply to this email directly, view it on GitHub
<#617 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE4OZCYISKF3H4FM2UE3HK32DFF73AVCNFSM6AAAAABSX2OEGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMBYHA2DEOJTGA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
With the updated draggable handle, I've found a use case where I'd like to be able to subscribe to isItemsDragDisabled.
The text was updated successfully, but these errors were encountered: