From 5d7baa96bd92e730a70f3c0335089af1808300da Mon Sep 17 00:00:00 2001 From: zeke Date: Mon, 13 Nov 2017 17:51:41 -0800 Subject: [PATCH] configurable manual zoom speed --- docs/network/interaction.html | 4 +++- lib/network/modules/InteractionHandler.js | 5 +++-- lib/network/options.js | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/network/interaction.html b/docs/network/interaction.html index 4be1c97b7..ad3deb159 100644 --- a/docs/network/interaction.html +++ b/docs/network/interaction.html @@ -70,7 +70,8 @@

Options

selectable: true, selectConnectedEdges: true, tooltipDelay: 300, - zoomView: true + zoomView: true, + zoomSpeed: 1 } } @@ -109,6 +110,7 @@

Options

selectConnectedEdges BooleantrueWhen true, on selecting a node, its connecting edges are highlighted. tooltipDelay Number 300 When nodes or edges have a defined 'title' 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. zoomView Boolean true When true, the user can zoom in. + zoomSpeed Number 1 The default speed of "1" (arbitrary unit) is moderately fast. Speed changes apply only to manual zooming (e.g. with mouse scroll wheel). diff --git a/lib/network/modules/InteractionHandler.js b/lib/network/modules/InteractionHandler.js index 1e62825b2..cbdc49013 100644 --- a/lib/network/modules/InteractionHandler.js +++ b/lib/network/modules/InteractionHandler.js @@ -53,7 +53,8 @@ class InteractionHandler { }, navigationButtons: false, tooltipDelay: 300, - zoomView: true + zoomView: true, + zoomSpeed: 1 }; util.extend(this.options,this.defaultOptions); @@ -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); } diff --git a/lib/network/options.js b/lib/network/options.js index ac9dc7931..ff614a5df 100644 --- a/lib/network/options.js +++ b/lib/network/options.js @@ -167,6 +167,7 @@ let allOptions = { hoverConnectedEdges: { boolean: bool }, tooltipDelay: { number }, zoomView: { boolean: bool }, + zoomSpeed: { number }, __type__: { object } }, layout: { @@ -572,7 +573,8 @@ let configureOptions = { selectConnectedEdges: true, hoverConnectedEdges: true, tooltipDelay: [300, 0, 1000, 25], - zoomView: true + zoomView: true, + zoomSpeed: 1 }, manipulation: { enabled: false,