Panning limits on resized (zoomed out) image

Hello ther heroes!

I am working on a map. I was able to make my image pan to all eight directions. and it works perfectly.

My problem is when I zoom out the borders of the map image is already seen since the panning limit remains the same.

Or in the case of zoom in, the other part of the map (near the edges) are no longer viewable (as i have not set to change the panning limits to change everytime the zoom-in or zoom out button is clicked)

What script should I add in order to increase my panning limits when zooming in or decrease the limits when zooming out.

Please help… :tired: