Is it possible to have a max pan offset (from elements?) after which, the canvas ends?

Say I have 5 blocks one under another and I can pan as usual. I need the top position to be 32px off the first block and not allow me to scroll past this position (up) and the bottom to behave the same way.

Like a boundary in which I can pan and zoom but not go out of it