Dragging and snapping polygons

Dragging and snapping polygons

I am trying to dragging and snapping two triangles without success using jQueryUI.
While the dragging function works like a charm, it seems possible just to snap squares or rectangles.
I have taken a look at the function and there seems to be a lack of functionality regarding even other polygons such as pentagons or hexagons. Any suggestion?