i'm trying to do an app that when u click outside a figure it let you pan the viewport using setviewbox(); i have done something close to it, but i'm not pleased with it, i'm using a rectangle:
canvas = new Raphael(0,0,canvas_size, canvas_size);
var rectan = paper.rect(0,0,canvas_size,canvas_size);
using .drag(move,dragger,up);
and in the function of move
var bboxx=this.getBBox(false)
paper.setViewBox(bboxx.x,bboxx.y,canvas_size,canvas_size,true);
this.toBack();
i send back so it cant mess with the others objects animations(drag....) it works but i still need to know if is possible and better click/ touch on the canvas instead of the rectangle
I recommend tihs library for panning and zooming, works great for me.
https://github.com/andrewseddon/raphael-zpd
Then if you want to pan only when click outside a shape, you just need to prevent or stop the events when click on any shape.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With