I thought your circle based camera was pretty creative. Unfortunately, it won't for every situation.
Understanding how the camera I made is pretty simple. There are 3 components that you need to deal with.
The viewport. The viewable area. What you can see. Basically a container, with overflow: hidden on it.
The world. It should be larger than the viewport, and is the parent container for everything.
The target. What you want to follow. It moves around the world.
And the rest is basically just knowing how to center a rectangle inside another rectangle. For those that don't, or need a refresher...
// Coordinates to center the smallBox inside the bigBox
var x = bigBox.width / 2 - smallBox.width / 2;
var y = bigBox.height / 2 - smallBox.height / 2;
// Or even simpler
var x = (bigBox.width - smallBox.width) / 2;
var y = (bigBox.height - smallBox.height) / 2;
We want the target to remain in the center of the viewport, so every time it moves, we'll need to update the camera. So start off by figuring out the coordinates to center it, just like above.
The target is moving around the world, so we can't move the target to those coordinates. Rather, we need to find out how far away the target is away from those coordinates, and then move the world by that difference. That will move the target into place, and now you have a functioning camera!
var x = (viewport.width - target.width) / 2;
var y = (viewport.height - target.height) / 2;
var dx = x - target.x;
var dy = y - target.y;
world.x += dx;
world.y += dy;