Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add background image with zoom in/out to sigma.js

I am using sigma.js and try to add background image instead of background color. It work find but not possible to zoom in/out. Someone already add a question here but no answer yet. So anyone have a solution of this issue?

like image 849
wut-excel Avatar asked Nov 08 '22 23:11

wut-excel


1 Answers

After a simple lucky search i found the following solution:

var c = s.camera;
// Zoom out - single frame :
c.goTo({
   ratio: c.ratio * c.settings('zoomingRatio')
});

// Zoom in - single frame :
c.goTo({
   ratio: c.ratio / c.settings('zoomingRatio')
});

// Zoom out - animation :
sigma.misc.animation.camera(c, {
   ratio: c.ratio * c.settings('zoomingRatio')
}, {
   duration: 200
});

// Zoom in - animation :
sigma.misc.animation.camera(c, {
   ratio: c.ratio / c.settings('zoomingRatio')
}, {
   duration: 200
});
like image 161
Bashar Abutarieh Avatar answered Nov 14 '22 23:11

Bashar Abutarieh