Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

configurable manual zoom speed #3657

Merged
merged 1 commit into from
Nov 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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