Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

direct canvas panning with raphael.js

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

like image 948
user979383 Avatar asked Oct 05 '11 14:10

user979383


1 Answers

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.

like image 177
limoragni Avatar answered Sep 22 '22 03:09

limoragni