Browse Source

Renamed keyboardNavigation to keyboard

css_transitions
josdejong 11 years ago
parent
commit
6805c1f918
4 changed files with 30 additions and 31 deletions
  1. +13
    -10
      docs/graph.html
  2. +2
    -6
      examples/graph/20_navigation.html
  3. +9
    -9
      src/graph/Graph.js
  4. +6
    -6
      src/graph/NavigationMixin.js

+ 13
- 10
docs/graph.html View File

@ -684,7 +684,7 @@ var options = {
</tr>
<tr>
<td><a href="#Keyboard_navigation">keyboardNavigation</a></td>
<td><a href="#Keyboard_navigation">keyboard</a></td>
<td>Object</td>
<td>none</td>
<td>
@ -1304,7 +1304,7 @@ var options: {
// advanced use of navigation controls
var options: {
navigation: {
iconPath: this._getIconURL() // automatic loading of the default icons
iconPath: '/path/to/navigation/icons/'
}
}
</pre>
@ -1333,17 +1333,20 @@ var options: {
</p>
<pre class="prettyprint">
// These variables must be defined in an options object named keyboardNavigation.
// If a variable is not supplied, the default value is used
// simple use of keyboard controls
var options: {
keyboardNavigation: {
enabled: false,
speed: {x: 10, y: 10, zoom: 0.02}
}
keyboard: true
}
// OR to just load the module with default values:
// advanced configuration for keyboard controls
var options: {
keyboardNavigation: true
keyboard: {
speed: {
x: 10,
y: 10,
zoom: 0.02
}
}
}
</pre>

+ 2
- 6
examples/graph/20_navigation.html View File

@ -110,12 +110,8 @@
length: 50
},
stabilize: false,
navigationUI: {
enabled: true
},
keyboardNavigation: {
enabled: true
}
navigation: true,
keyboard: true
};
graph = new vis.Graph(container, data, options);

+ 9
- 9
src/graph/Graph.js View File

@ -90,7 +90,7 @@ function Graph (container, data, options) {
enabled: false,
iconPath: this._getIconURL()
},
keyboardNavigation: {
keyboard: {
enabled: false,
speed: {x: 10, y: 10, zoom: 0.02}
},
@ -405,16 +405,16 @@ Graph.prototype.setOptions = function (options) {
this.constants.navigation.enabled = false;
}
if (options.keyboardNavigation) {
this.constants.keyboardNavigation.enabled = true;
for (var prop in options.keyboardNavigation) {
if (options.keyboardNavigation.hasOwnProperty(prop)) {
this.constants.keyboardNavigation[prop] = options.keyboardNavigation[prop];
if (options.keyboard) {
this.constants.keyboard.enabled = true;
for (var prop in options.keyboard) {
if (options.keyboard.hasOwnProperty(prop)) {
this.constants.keyboard[prop] = options.keyboard[prop];
}
}
}
else if (options.keyboardNavigation !== undefined) {
this.constants.keyboardNavigation.enabled = false;
else if (options.keyboard !== undefined) {
this.constants.keyboard.enabled = false;
}
@ -567,7 +567,7 @@ Graph.prototype._createKeyBinds = function() {
this.mousetrap.reset();
if (this.constants.keyboardNavigation.enabled == true) {
if (this.constants.keyboard.enabled == true) {
this.mousetrap.bind("up", this._moveUp.bind(me) , "keydown");
this.mousetrap.bind("up", this._yStopMoving.bind(me), "keyup");
this.mousetrap.bind("down", this._moveDown.bind(me) , "keydown");

+ 6
- 6
src/graph/NavigationMixin.js View File

@ -140,7 +140,7 @@ var NavigationMixin = {
*/
_moveUp : function(event) {
this._highlightUIElement("UI_up");
this.yIncrement = this.constants.keyboardNavigation.speed.y;
this.yIncrement = this.constants.keyboard.speed.y;
this.start(); // if there is no node movement, the calculation wont be done
this._preventDefault(event);
},
@ -152,7 +152,7 @@ var NavigationMixin = {
*/
_moveDown : function(event) {
this._highlightUIElement("UI_down");
this.yIncrement = -this.constants.keyboardNavigation.speed.y;
this.yIncrement = -this.constants.keyboard.speed.y;
this.start(); // if there is no node movement, the calculation wont be done
this._preventDefault(event);
},
@ -164,7 +164,7 @@ var NavigationMixin = {
*/
_moveLeft : function(event) {
this._highlightUIElement("UI_left");
this.xIncrement = this.constants.keyboardNavigation.speed.x;
this.xIncrement = this.constants.keyboard.speed.x;
this.start(); // if there is no node movement, the calculation wont be done
this._preventDefault(event);
},
@ -176,7 +176,7 @@ var NavigationMixin = {
*/
_moveRight : function(event) {
this._highlightUIElement("UI_right");
this.xIncrement = -this.constants.keyboardNavigation.speed.y;
this.xIncrement = -this.constants.keyboard.speed.y;
this.start(); // if there is no node movement, the calculation wont be done
this._preventDefault(event);
},
@ -188,7 +188,7 @@ var NavigationMixin = {
*/
_zoomIn : function(event) {
this._highlightUIElement("UI_plus");
this.zoomIncrement = this.constants.keyboardNavigation.speed.zoom;
this.zoomIncrement = this.constants.keyboard.speed.zoom;
this.start(); // if there is no node movement, the calculation wont be done
this._preventDefault(event);
},
@ -200,7 +200,7 @@ var NavigationMixin = {
*/
_zoomOut : function() {
this._highlightUIElement("UI_min");
this.zoomIncrement = -this.constants.keyboardNavigation.speed.zoom;
this.zoomIncrement = -this.constants.keyboard.speed.zoom;
this.start(); // if there is no node movement, the calculation wont be done
this._preventDefault(event);
},

Loading…
Cancel
Save