Skip to content

Commit

Permalink
feat(interaction-handler): add the ability to skip highlight when bin… (
Browse files Browse the repository at this point in the history
#1537)

* feat(interaction-handler): add the ability to skip highlight when bindToWindow is false

* feat(interaction-handler): add skipHighlight to the docs

* refactor(interaction-handler): rename skipHighlight to autoFocus that defaults to true

Co-authored-by: Matan Sar-Shalom <[email protected]>
Co-authored-by: Tomina <[email protected]>
  • Loading branch information
3 people authored Aug 29, 2021
1 parent 8455e39 commit ea66a94
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs-kr/network/interaction.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ <h3>옵션</h3>
keyboard: {
enabled: false,
speed: {x: 10, y: 10, zoom: 0.02},
bindToWindow: true
bindToWindow: true,
autoFocus: true,
},
multiselect: false,
navigationButtons: false,
Expand Down
12 changes: 11 additions & 1 deletion docs/network/interaction.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ <h3>Options</h3>
keyboard: {
enabled: false,
speed: {x: 10, y: 10, zoom: 0.02},
bindToWindow: true
bindToWindow: true,
autoFocus: true,
},
multiselect: false,
navigationButtons: false,
Expand Down Expand Up @@ -317,6 +318,15 @@ <h3>Options</h3>
keyboard shortcuts only work on the network that has the focus.
</td>
</tr>
<tr parent="keyboard" class="hidden">
<td class="indent">keyboard.autoFocus</td>
<td>Boolean</td>
<td><code>true</code></td>
<td>
When <code>keyboard.bindToWindow=false</code> this option allows you
to skip auto focusing the network on hover.
</td>
</tr>
<tr>
<td>multiselect</td>
<td>Boolean</td>
Expand Down
2 changes: 2 additions & 0 deletions lib/network/modules/InteractionHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class InteractionHandler {
enabled: false,
speed: { x: 10, y: 10, zoom: 0.02 },
bindToWindow: true,
autoFocus: true,
},
navigationButtons: false,
tooltipDelay: 300,
Expand Down Expand Up @@ -647,6 +648,7 @@ class InteractionHandler {

// if we bind the keyboard to the div, we have to highlight it to use it. This highlights it on mouse over.
if (
this.options.keyboard.autoFocus &&
this.options.keyboard.bindToWindow === false &&
this.options.keyboard.enabled === true
) {
Expand Down
2 changes: 2 additions & 0 deletions lib/network/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ const allOptions: OptionsConfig = {
__type__: { object },
},
bindToWindow: { boolean: bool },
autoFocus: { boolean: bool },
__type__: { object, boolean: bool },
},
multiselect: { boolean: bool },
Expand Down Expand Up @@ -759,6 +760,7 @@ const configureOptions: ConfiguratorConfig = {
zoom: [0.02, 0, 0.1, 0.005],
},
bindToWindow: true,
autoFocus: true,
},
multiselect: false,
navigationButtons: false,
Expand Down

0 comments on commit ea66a94

Please sign in to comment.