Skip to content

Commit f62a25b

Browse files
Zoom in, zoom out and reset view buttons add
1 parent 307d35d commit f62a25b

File tree

7 files changed

+65
-8
lines changed

7 files changed

+65
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iknow-entity-browser",
3-
"version": "0.7.2",
3+
"version": "0.7.3",
44
"description": "Visualizer for iKnow entities",
55
"main": "gulpfile.babel.js",
66
"scripts": {

src/static/index.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@
2626
</div>
2727
</div>
2828
</div>
29+
<div id="zoomInButton" class="ui icon-zoom-in hint">
30+
<div class="right tooltip">
31+
<div class="two-line label">
32+
<div>Zoom In</div>
33+
<div class="sub">Use mouse/gestures as well</div>
34+
</div>
35+
</div>
36+
</div>
37+
<div id="resetZoomButton" class="ui icon-search hint">
38+
<div class="right tooltip">
39+
<div class="label">
40+
Reset View
41+
</div>
42+
</div>
43+
</div>
44+
<div id="zoomOutButton" class="ui icon-zoom-out hint">
45+
<div class="right tooltip">
46+
<div class="two-line label">
47+
<div>Zoom Out</div>
48+
<div class="sub">Use mouse/gestures as well</div>
49+
</div>
50+
</div>
51+
</div>
2952
</div>
3053
<svg id="graph">
3154
<defs>

src/static/js/controls.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
*/
44
import { onSelectionUpdate, updateSelection } from "./selection";
55
import { dropDescendants, dropNodes } from "./model";
6-
import { updateSelected } from "./graph"
6+
import { updateSelected, scaleBy, resetZoom } from "./graph"
77

88
let dropChildrenButton = null,
99
removeButton = null,
1010
resetSelectionButton = null,
11+
zoomInButton = null,
12+
resetViewButton = null,
13+
zoomOutButton = null,
1114
selection = [];
1215

1316
onSelectionUpdate((sel) => {
@@ -54,5 +57,11 @@ export function init () {
5457
removeButton.addEventListener("click", deleteSelection);
5558
resetSelectionButton = document.getElementById(`resetSelectionButton`);
5659
resetSelectionButton.addEventListener(`click`, resetSelection);
60+
zoomInButton = document.getElementById(`zoomInButton`);
61+
zoomInButton.addEventListener("click", () => scaleBy(1.5));
62+
resetViewButton = document.getElementById(`resetZoomButton`);
63+
resetViewButton.addEventListener("click", () => resetZoom());
64+
zoomOutButton = document.getElementById(`zoomOutButton`);
65+
zoomOutButton.addEventListener("click", () => scaleBy(0.75));
5766
updateButtons();
5867
}

src/static/js/graph/index.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { onModelUpdate, unfold, dropNodes } from "../model";
1+
import { onModelUpdate, unfold, dropNodesm, uiState } from "../model";
22
import { updateSelection, selectAll, deselectAll } from "../selection";
33

44
let shiftKey, ctrlKey,
@@ -50,12 +50,29 @@ let svg = null,
5050
}),
5151
view = null;
5252

53-
export function translateZoom (x = 0, y = 0) {
53+
export function translateBy (x = 0, y = 0) {
5454
svg.transition()
5555
.duration(300)
5656
.call(zoomer.translateBy, x, y);
5757
}
5858

59+
export function scaleBy (delta = 1) {
60+
svg.transition()
61+
.duration(300)
62+
.call(zoomer.scaleBy, delta);
63+
}
64+
65+
export function resetZoom () {
66+
svg.transition()
67+
.duration(300)
68+
.call(zoomer.transform, d3.zoomIdentity.translate(
69+
uiState.tabularToggled
70+
? - document.getElementById("table").getBoundingClientRect().width / 2
71+
: 0,
72+
0)
73+
);
74+
}
75+
5976
export function updateSelected () {
6077
node.classed("selected", p => p.selected);
6178
}

src/static/js/tabular/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from "../selection";
66
import { getOption } from "../settings/values";
77
import { getObjProp } from "../utils";
8-
import { translateZoom } from "../graph";
8+
import { translateBy } from "../graph";
99

1010
let sorting = {
1111
properties: ["entities", "0", "frequency"],
@@ -148,7 +148,7 @@ export function init () {
148148
if (d.tabularToggled)
149149
updateAll();
150150
let w = document.getElementById("table").getBoundingClientRect().width / 2;
151-
translateZoom(d.tabularToggled ? -w : w);
151+
translateBy(d.tabularToggled ? -w : w);
152152
});
153153

154154
d3.select("#exportCSV").on("click", () => {

src/static/scss/hint.scss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,17 @@
2626
visibility: hidden;
2727
border-radius: 4px;
2828
opacity: 0;
29+
top: 50%;
2930
@include transition(opacity .3s ease);
3031

32+
&.two-line {
33+
top: 25%;
34+
}
35+
36+
.sub {
37+
font-size: 8pt;
38+
}
39+
3140
&:after {
3241
content: '';
3342
position: absolute;
@@ -48,7 +57,6 @@
4857
> .label {
4958
visibility: visible;
5059
right: 100%;
51-
top: 50%;
5260
margin-top: -15px;
5361
margin-right: 15px;
5462
z-index: 999;

src/static/scss/icons.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@charset "UTF-8";
22

3-
// change here: http://app.fontastic.me/#publish/font/S2ZmpBbsKYvHqsjEzTVzeP
3+
// change here: http://app.fontastic.me/#customize/S2ZmpBbsKYvHqsjEzTVzeP
44

55
@font-face {
66
font-family: "iknowentitybrowsericons";

0 commit comments

Comments
 (0)