Clipping node in drag event

Hi

Question: Is it possible to ‘clip’ a node to the bounds of a panel when dragging.

Clarification: Yes - I do mean dragging a node over a panel, not a part within a panel.

Scenario: The scenario is that I have a node drawn ‘over’ a panel. I wish to let the user drag the node but if the drag causes the dragged node to be positioned ‘outside’ the panel I want the part of the node that exceeds the bounds of the panel to become ‘clipped’ out of sight. The real world use case is a Gantt chart where the panel is the background to the chart and the node being dragged is a task bar - drag left to move back on the timeline and right to move ahead. The task should be constrained within the chart.

I wonder if this would be possible with a Group if the Placeholder could be set to have fixed bounds - possible ? I concur that the default behaviour of the placeholder flexing to encompass the grouped nodes is good, it’s just that I need it to be fixed bounds. (I read the Group placeholder explanation here See http://gojs.net/latest/intro/groups.html)

As a potential fall-back, I wonder if it would be possible to clip the node within the diagram assuming it is possible to stop the auto-scroll of the diagram.Is this correct ? If so are there any examples that demonstrate this feature ? This would allow me to upscale the panels to separate diagrams and achieve the clipping effect in that way.

I also appreciate that the minLocation and maxLocation can be used to constrain the drag.

Well, so you already know that the Diagram automatically clips everything that is outside of the viewport. I think that is what you are utilizing in your fall-back plan, yes?

But many kinds of Panels can clip their element(s) within the rectangular bounds of the panel. This is demonstrated by a few examples at http://gojs.net/latest/intro/panels.html and at the end of http://gojs.net/latest/intro/sizing.html. As you might expect, this is not a “normal” thing.

So you could artificially change the sizes of Nodes (if their element(s) are fixed size) within a “SelectionMoved” DiagramEvent listener.

Thanks. The case I am working on needs nodes that are clipped or ‘appear’ to go behind other elements when dragged. I followed up with the idea of switching the main panels for diagrams and it seems to be the way to go. I also have to recompute some of the layout if a node is dragged out of view - though I might trade that for using the diagram auto-scroll and prepare the extra background pre-emptively.

Thanks for the pointers on panels and clipping, useful to know.