Repel Force around the Boundary

So essentially I am done with this challenge as shown here:

However, I am having trouble implementing the similar behavior of FCC’s example, where the nodes are repealed when it reaches across or near the boundary.

In my version, it stays in the boundary. I’ve read the d3.js V4 documents, yet I cannot find anything that would solve my case.

Does anyone have a suggestion?