Prevent Layer from going off screen CCLayerPanZoom

I am using the CCLayerPanZoom class to display an image. Currently, I pan the layer and move it out of the screen. How do I prevent the layer from going out of the screen ?
The code for the CCLayerPanZoom class is given here http://www.cocos2d-x.org/boards/6/topics/5430?r=17421#message-17421