Skip to content

Commit

Permalink
Fixed #211: Added default camera getter
Browse files Browse the repository at this point in the history
Sigma instances now have a "camera" getter to retrieve the first registered camera.
  • Loading branch information
jacomyal committed Mar 4, 2014
1 parent 4a7011d commit 602683f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/add-node-on-click.html
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
dom = document.querySelector('#graph-container canvas:last-child');
disc = document.getElementById('disc');
ground = document.getElementById('ground');
c = s.cameras[0];
c = s.camera;

// Initialize graph:
s.graph.read({
Expand Down
4 changes: 2 additions & 2 deletions examples/neighborhoods-plugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
}
});
document.getElementById('restart-camera').addEventListener('click', function() {
s.cameras[0].goTo({
s.camera.goTo({
x: 0,
y: 0,
angle: 0,
Expand All @@ -94,7 +94,7 @@
s.stopForceAtlas2();

// Restart the camera:
s.cameras[0].goTo({
s.camera.goTo({
x: 0,
y: 0,
angle: 0,
Expand Down
5 changes: 5 additions & 0 deletions src/sigma.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@
value: {},
configurable: true
});
Object.defineProperty(this, 'camera', {
get: function() {
return this.cameras[0];
}
});

// Add a custom handler, to redispatch events from renderers:
this._handler = (function(e) {
Expand Down

0 comments on commit 602683f

Please sign in to comment.