Example for the Stackoverflow question: How can I contain D3 JS animation within a container
The balls use a modified version of the D3.js Force Layout. Parts of the code, such as the collision function are taken from Mike Bostock's example Multi-Foci Force Layout.
Modified http://d3js.org/d3.v3.js to a secure url
https://d3js.org/d3.v3.js