I\'m currently trying to create draggable behavior in my d3 script. I\'m studying Mike Bostock\'s example here: http://bl.ocks.org/mbostock/1557377
This is the function
It's being used to limit the drag range of each circle.
x is being limited to the range [radius, width-radius]
y is being limited to the range [radius, height-radius]
These are all inside an appropriately transformed svg g
element so that x and y are relative to each cell. Hence the edges of the circles will cross the cell boundary when dragged.