The dragging behavior can be limited with some configurable constraints.
In this recipe, we will see how to drag an element either horizontally or vertically, on a grid or inside a certain section on the page.
The next example demonstrates three draggable panels and one draggable image. The first panel can be dragged only horizontally, the second one only vertically, and the third panel is dragged on a grid. Dragging on a grid means the dragging helper snaps to a grid—every specific x and y pixels. The image is placed within an
h:panelGroup tag, which acts as a container for dragging. The image cannot go outside of this container.
<p:panel id="hpnl" header="Only horizontal draggable ...