Explaining Mike Bostock's d3.js dragmove function

前端 未结 1 618
逝去的感伤
逝去的感伤 2021-01-24 23:24

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

相关标签:
1条回答
  • 2021-01-24 23:50

    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.

    0 讨论(0)
提交回复
热议问题