8

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

user979383
  • 81
  • 3
  • Look at the OP's answer, not accepted one: http://stackoverflow.com/questions/4157590/raphael-canvasbackground-onclick-event – unclenorton Nov 21 '11 at 13:44

1 Answers1

2

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.

limoragni
  • 2,716
  • 2
  • 32
  • 50