-
-
Notifications
You must be signed in to change notification settings - Fork 707
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
Add targetNode to canDrag rule #26
Comments
The other 2 Canvas-specific rules exposes the incoming/outgoing child Node and their own corresponding For your use-case, you can use the canDrag: (node, helpers) => {
return helpers(node.parent).get().data.type == BoxListContainer
} |
Nice, I noticed the helpers there and thought I could get the target node, thanks for pointing out Anyway, on the other hand, wouldn't it make sense to make the signature of all rules similar? After all, dragging is always done in relation, so I think it makes sense to put
To defend this proposal, I think it will actually be quite common to do both:
With this change, it will be much easier to write the logic, so instead of having to update, say, 3 Canvases to accept a new Component, we can simply implement the logic in the Component itself.
With that being said, I would also suggest to change the terminology to
So one does not need to think in terms of current, incoming, outgoing. In fact, when I was writing the other issue #27 I was confused a little bit when figuring out what is currentNode in the context of dragging a Component out of Canvas. I assumed current is the one "I am currently dragging" and that Anyway, if you were to adopt this terminology change, why not allow calling all three rules on both Canvases and Components? I think it makes perfect sense. See this use case: I have a text component which I want to be draggable if it contains text "hello",
Without the change, it would have to be written like this
i) this one is tricky, since we only want to prevent drag when the Text is already a child of LockBox, not when it is being just dragged into. And the logic for the rules would be relatively simple A Component that is Hoveringrules
### use cases and call order, only continue to next rule if the previous is true
A Canvas that is being Hoveredrules
### use cases and call order Oh man, I have gone a little wild here. PS: I have just realised a Canvas can be draggable as well, so it will have to have separate
or Just for record, this would have been the other suggestion.
|
You really went a little wild here 😂 But I get what you're saying.
The The reason why there is no
In regards to the current implementation, I disagree with changing |
Then you really suggest to use a hack to prevent a Component to be droppable anywhere but one Canvas? This use case is actually more common than having a Canvas decide which components it can accept. Given I have a BoxItem Component and a BoxContainer Canvas, I need to prevent BoxItem to be droppable anywhere but into BoxContainer. I would literally have to edit every single Canvas in every possible Component to make sure it will not accept BoxItem. And if I were to import external component, which I don't even have a control over, then there wouldn't really be a solution whatsoever (other than the Forgive me, but this is not right. |
Actually, the workaround doesn't help me
I need the target element I am hovering over. If I am currently dragging a BoxItem, it's not a child of the BoxListContainer yet. Any suggestions? |
It seems to me now that you're interested in implementing a But anyways, with that brief example of yours, a
If you were to import an external component and you want to use as a p.s. Stop spamming the issues tracker. We can use Discord for more long-winded discussions such as this. It also doesn't help that you occasionally post your questions/issues on both platforms. |
My company blocks Discord since yesterday 😆 At first, my idea was to post some long texts and examples here and do the quick instant messaging on discords with reference to the issue here.
Allright, let me take a look at it. I will try to implement that. |
|
Because there is a use case to lock a Component inside a Canvas, but keep the logic coupled to the component, not the Canvas. It's similar to how I envision the I believe that both Canvas and Component should agree on the Component leaving. if both But I understand that |
Isn't this use case supported by canDrag: (node, helpers) => {
const parent = helpers.get(node.parent);
if ( parent.data.type == BoxListContainer ) return false;
return true;
} Currently, Craft depends on both the component's |
I have a BoxListContainer and BoxListItem
The BoxListContainer is set to only accept BoxListItems
Now I need to also set that BoxListItem can be dragged only into BoxListContainer. How do I do that?
I am missing
targetNode
incanDrag
, the other two have both nodes available.this:
The text was updated successfully, but these errors were encountered: