You can do something like this, basically just make sure the viewport always keeps track of the object on the canvas , taking into account the coordinates of the canvas relative to the page.
function track(x,y, offsetX, offsetY){ var trackX = x - (canvas.offsetLeft + offsetX); trackY = y - (canvas.offsetTop + offsetY); window.scrollTo(trackX, trackY); }
Live demo
source share