Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Commit

Permalink
configurable manual zoom speed (almende#3657)
Browse files Browse the repository at this point in the history
  • Loading branch information
evictor authored and mojoaxel committed Jun 9, 2019
1 parent e02c521 commit 317953f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion docs/network/interaction.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ <h3>Options</h3>
selectable: true,
selectConnectedEdges: true,
tooltipDelay: 300,
zoomView: true
zoomView: true,
zoomSpeed: 1
}
}

Expand Down Expand Up @@ -109,6 +110,7 @@ <h3>Options</h3>
<tr><td>selectConnectedEdges</td> <td>Boolean</td><td><code>true</code></td><td>When true, on selecting a node, its connecting edges are highlighted.</td></tr>
<tr><td>tooltipDelay</td> <td>Number</td> <td><code>300</code></td> <td>When nodes or edges have a defined <code>'title'</code> field, this can be shown as a pop-up tooltip. The tooltip itself is an HTML element that can be fully styled using CSS. The delay is the amount of time in milliseconds it takes before the tooltip is shown.</td></tr>
<tr><td>zoomView</td> <td>Boolean</td> <td><code>true</code></td> <td>When true, the user can zoom in.</td></tr>
<tr><td>zoomSpeed</td> <td>Number</td> <td><code>1</code></td> <td>The default speed of "1" (arbitrary unit) is moderately fast. Speed changes apply only to manual zooming (e.g. with mouse scroll wheel).</td></tr>
</table>

</div>
Expand Down
5 changes: 3 additions & 2 deletions lib/network/modules/InteractionHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class InteractionHandler {
},
navigationButtons: false,
tooltipDelay: 300,
zoomView: true
zoomView: true,
zoomSpeed: 1
};
util.extend(this.options,this.defaultOptions);

Expand Down Expand Up @@ -520,7 +521,7 @@ class InteractionHandler {

// calculate the new scale
let scale = this.body.view.scale;
let zoom = delta / 10;
let zoom = delta * (this.options.zoomSpeed / 10);
if (delta < 0) {
zoom = zoom / (1 - zoom);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/network/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ let allOptions = {
hoverConnectedEdges: { boolean: bool },
tooltipDelay: { number },
zoomView: { boolean: bool },
zoomSpeed: { number },
__type__: { object }
},
layout: {
Expand Down Expand Up @@ -572,7 +573,8 @@ let configureOptions = {
selectConnectedEdges: true,
hoverConnectedEdges: true,
tooltipDelay: [300, 0, 1000, 25],
zoomView: true
zoomView: true,
zoomSpeed: 1
},
manipulation: {
enabled: false,
Expand Down

0 comments on commit 317953f

Please sign in to comment.