hammer.js pan limit—how to set boundaries
Asked Answered
C

0

7

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 pans great, but with the current code I can keep panning until the image is off the screen. How do I limit it so the image only goes e.g. half way off the screen before you can't pan in that direction any more? Is there a preset option in Hammer.js for that?

Correll answered 24/10, 2016 at 1:55 Comment(1)
did you manage to solve your problem?Unorganized

© 2022 - 2024 — McMap. All rights reserved.