Hammer.js pan limit - how to set boundaries

I currently have this code:

var hammertime = new Hammer(canvasContainer);
var x0, y0;
hammertime.on('panstart', function(ev){
 x0=stage.position.x;
 y0=stage.position.y;
});
hammertime.on('pan', function(ev){
  stage.position.x = x0 + ev.deltaX;
  stage.position.y = y0+ ev.deltaY;
  renderer.render(stage);

});

This works well, but with the current code I can keep panning until the image is disconnected from the screen. How to limit it, so that the image only goes, for example. halfway from the screen before you can no longer swing in that direction? Is there a predefined parameter in Hammer.js for this?

+4
source share

Source: https://habr.com/ru/post/1658636/