Browse Source

feat: add pointer position to zoom event (#2377)

* add pointer position to zoom event
* Update docs with zoom api
codeClimate
yoavdamri 8 years ago
committed by Alexander Wunschik
parent
commit
eeba7fd05d
3 changed files with 12 additions and 6 deletions
  1. +8
    -2
      docs/network/index.html
  2. +2
    -2
      lib/network/modules/InteractionHandler.js
  3. +2
    -2
      lib/network/modules/components/NavigationHandler.js

+ 8
- 2
docs/network/index.html View File

@ -1400,8 +1400,14 @@ var options = {
<td>Fired if the option <code>interaction:{hover:true}</code> is enabled and the mouse moved away from an edge it was hovering over before.</td> <td>Fired if the option <code>interaction:{hover:true}</code> is enabled and the mouse moved away from an edge it was hovering over before.</td>
</tr> </tr>
<tr><td id="event_zoom">zoom</td> <tr><td id="event_zoom">zoom</td>
<td><code>{direction:'+'/'-', scale: Number}</code></td>
<td>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().</td>
<td>Object</td>
<td>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:
<pre class="prettyprint lang-js">{
direction: '+'/'-',
scale: Number,
pointer: {x:pointer_x, y:pointer_y}
}
</pre></td>
</tr> </tr>
<tr><td id="event_showPopup">showPopup</td> <tr><td id="event_showPopup">showPopup</td>
<td><code>id of item corresponding to popup</code></td> <td><code>id of item corresponding to popup</code></td>

+ 2
- 2
lib/network/modules/InteractionHandler.js View File

@ -472,10 +472,10 @@ class InteractionHandler {
this.body.emitter.emit('_requestRedraw'); this.body.emitter.emit('_requestRedraw');
if (scaleOld < scale) { 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 { 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});
} }
} }
} }

+ 2
- 2
lib/network/modules/components/NavigationHandler.js View File

@ -160,7 +160,7 @@ class NavigationHandler {
this.body.view.scale = scale; this.body.view.scale = scale;
this.body.view.translation = { x: tx, y: ty }; 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() { _zoomOut() {
var scaleOld = this.body.view.scale; var scaleOld = this.body.view.scale;
@ -172,7 +172,7 @@ class NavigationHandler {
this.body.view.scale = scale; this.body.view.scale = scale;
this.body.view.translation = { x: tx, y: ty }; 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 });
} }

Loading…
Cancel
Save