From 5476b2155a69594c4c55ab802b7e3427594034ba Mon Sep 17 00:00:00 2001 From: YD Date: Tue, 29 Nov 2016 08:21:41 +0200 Subject: [PATCH 1/2] add pointer position to zoom event --- lib/network/modules/InteractionHandler.js | 4 ++-- lib/network/modules/components/NavigationHandler.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/network/modules/InteractionHandler.js b/lib/network/modules/InteractionHandler.js index b4e6fec4d..14ab3a7e8 100644 --- a/lib/network/modules/InteractionHandler.js +++ b/lib/network/modules/InteractionHandler.js @@ -472,10 +472,10 @@ class InteractionHandler { this.body.emitter.emit('_requestRedraw'); if (scaleOld < scale) { - this.body.emitter.emit('zoom', {direction: '+', scale: this.body.view.scale}); + this.body.emitter.emit('zoom', {direction: '+', scale: this.body.view.scale, pointer: pointer}); } else { - this.body.emitter.emit('zoom', {direction: '-', scale: this.body.view.scale}); + this.body.emitter.emit('zoom', {direction: '-', scale: this.body.view.scale, pointer: pointer}); } } } diff --git a/lib/network/modules/components/NavigationHandler.js b/lib/network/modules/components/NavigationHandler.js index 143478146..befe3063a 100644 --- a/lib/network/modules/components/NavigationHandler.js +++ b/lib/network/modules/components/NavigationHandler.js @@ -160,7 +160,7 @@ class NavigationHandler { this.body.view.scale = scale; this.body.view.translation = { x: tx, y: ty }; - this.body.emitter.emit('zoom', { direction: '+', scale: this.body.view.scale }); + this.body.emitter.emit('zoom', { direction: '+', scale: this.body.view.scale, pointer: pointer }); } _zoomOut() { var scaleOld = this.body.view.scale; @@ -172,7 +172,7 @@ class NavigationHandler { this.body.view.scale = scale; this.body.view.translation = { x: tx, y: ty }; - this.body.emitter.emit('zoom', { direction: '-', scale: this.body.view.scale }); + this.body.emitter.emit('zoom', { direction: '-', scale: this.body.view.scale, pointer: pointer }); } From 5977dd65e761668f5052fc533ccdca43034eac02 Mon Sep 17 00:00:00 2001 From: YD Date: Tue, 29 Nov 2016 12:36:13 +0200 Subject: [PATCH 2/2] Update docs with zoom api --- docs/network/index.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/network/index.html b/docs/network/index.html index cfd03d641..2742e3b8c 100644 --- a/docs/network/index.html +++ b/docs/network/index.html @@ -1400,8 +1400,14 @@

Events

Fired if the option interaction:{hover:true} is enabled and the mouse moved away from an edge it was hovering over before. zoom - {direction:'+'/'-', scale: Number} - Fired when the user zooms in or out. The properties tell you which direction the zoom is in. The scale is a number greater than 0, which is the same that you get with network.getScale(). + Object + Fired when the user zooms in or out. The properties tell you which direction the zoom is in. The scale is a number greater than 0, which is the same that you get with network.getScale(), Passes an object with properties structured as: +
{
+  direction: '+'/'-',
+  scale: Number,
+  pointer: {x:pointer_x, y:pointer_y}
+}
+
showPopup id of item corresponding to popup