Skip to content

Commit f1ca2f9

Browse files
authored
Merge pull request #581 from OpenKnowledgeMaps/back-button-zoom
Back/forward button zoom in, zoom out, select and deselect paper.
2 parents 182bb9b + 165fe68 commit f1ca2f9

17 files changed

Lines changed: 412 additions & 100 deletions

vis/js/actions/index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const NOT_QUEUED_IN_ANIMATION = [
2020
"ZOOM_OUT",
2121
"SELECT_PAPER",
2222
"DESELECT_PAPER",
23-
"DESELECT_PAPER_BACKLINK",
2423
"FILE_CLICKED",
2524
"SEARCH",
2625
"FILTER",
@@ -29,20 +28,23 @@ export const NOT_QUEUED_IN_ANIMATION = [
2928

3029
export const zoomIn = (
3130
selectedAreaData,
32-
source = null,
3331
callback,
34-
alreadyZoomed = false
32+
alreadyZoomed = false,
33+
isFromBackButton = false,
34+
selectedPaperData = null
3535
) => ({
3636
type: "ZOOM_IN",
3737
selectedAreaData,
38-
source,
3938
callback,
4039
alreadyZoomed,
40+
isFromBackButton,
41+
selectedPaperData,
4142
});
4243

43-
export const zoomOut = (callback) => ({
44+
export const zoomOut = (callback, isFromBackButton = false) => ({
4445
type: "ZOOM_OUT",
4546
callback,
47+
isFromBackButton,
4648
});
4749

4850
/**
@@ -97,10 +99,11 @@ export const filter = (id) => ({ type: "FILTER", id });
9799

98100
export const sort = (id) => ({ type: "SORT", id });
99101

100-
export const selectPaper = (paper) => ({
102+
export const selectPaper = (paper, isFromBackButton = false) => ({
101103
type: "SELECT_PAPER",
102104
safeId: paper.safe_id,
103105
paper,
106+
isFromBackButton,
104107
});
105108

106109
export const deselectPaper = () => ({ type: "DESELECT_PAPER" });
@@ -114,10 +117,6 @@ export const showPreview = (paper) => ({ type: "SHOW_PREVIEW", paper });
114117

115118
export const hidePreview = () => ({ type: "HIDE_PREVIEW" });
116119

117-
export const deselectPaperBacklink = () => ({
118-
type: "DESELECT_PAPER_BACKLINK",
119-
});
120-
121120
export const updateDimensions = (chart, list) => ({
122121
type: "RESIZE",
123122
listHeight: list.height,

vis/js/components/KnowledgeMap.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const KnowledgeMap = (props) => {
3434
};
3535

3636
const handleOtherAreaZoomIn = (bubble) => {
37-
handleDeselectPaper();
3837
handleZoomIn(bubble, true);
3938
trackMatomoEvent("Knowledge map", "Zoom in", "Bubble");
4039
};

vis/js/components/Streamgraph.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
TOOLTIP_OFFSET,
2626
} from "../utils/streamgraph";
2727

28-
import { deselectPaper, zoomIn, zoomOut } from "../actions";
28+
import { zoomIn, zoomOut } from "../actions";
2929

3030
/**
3131
* Class representing the streamgraph visualization.
@@ -541,7 +541,6 @@ const mapStateToProps = (state) => ({
541541

542542
const mapDispatchToProps = (dispatch) => ({
543543
onAreaClick: (stream) => {
544-
dispatch(deselectPaper());
545544
dispatch(
546545
zoomIn({ title: stream.key, color: stream.color, docIds: stream.docIds })
547546
);

vis/js/components/listentries/BasicListEntries.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import { shorten } from "../../utils/string";
1515
const BasicListEntries = ({
1616
displayedData,
1717
handleZoomIn,
18-
handleSelectPaper,
19-
handleDeselectPaper,
18+
handleSelectPaperWithZoom,
2019
handlePDFClick,
2120
handleAreaMouseover,
2221
handleAreaMouseout,
@@ -31,16 +30,14 @@ const BasicListEntries = ({
3130
if (disableClicks) {
3231
return;
3332
}
34-
handleSelectPaper(paper);
35-
handleZoomIn(paper);
33+
handleSelectPaperWithZoom(paper);
3634
};
3735

3836
const handleAreaClick = (paper) => {
3937
if (disableClicks) {
4038
return;
4139
}
42-
handleDeselectPaper();
43-
handleZoomIn(paper, "list-area");
40+
handleZoomIn(paper);
4441
};
4542

4643
return (

vis/js/components/listentries/ClassificationListEntries.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const ClassificationListEntries = ({
2727
disableClicks,
2828
handleZoomIn,
2929
handleSelectPaper,
30-
handleDeselectPaper,
30+
handleSelectPaperWithZoom,
3131
handlePDFClick,
3232
handleAreaMouseover,
3333
handleAreaMouseout,
@@ -37,18 +37,18 @@ const ClassificationListEntries = ({
3737
if (disableClicks) {
3838
return;
3939
}
40-
handleSelectPaper(paper);
4140
if (!isStreamgraph) {
42-
handleZoomIn(paper);
41+
handleSelectPaperWithZoom(paper);
42+
} else {
43+
handleSelectPaper(paper);
4344
}
4445
};
4546

4647
const handleAreaClick = (paper) => {
4748
if (disableClicks) {
4849
return;
4950
}
50-
handleDeselectPaper();
51-
handleZoomIn(paper, "list-area");
51+
handleZoomIn(paper);
5252
};
5353

5454
return (

vis/js/components/listentries/StandardListEntries.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const StandardListEntries = ({
3434
disableClicks,
3535
handleZoomIn,
3636
handleSelectPaper,
37-
handleDeselectPaper,
37+
handleSelectPaperWithZoom,
3838
handlePDFClick,
3939
handleAreaMouseover,
4040
handleAreaMouseout,
@@ -44,18 +44,18 @@ const StandardListEntries = ({
4444
if (disableClicks) {
4545
return;
4646
}
47-
handleSelectPaper(paper);
4847
if (!isStreamgraph) {
49-
handleZoomIn(paper);
48+
handleSelectPaperWithZoom(paper);
49+
} else {
50+
handleSelectPaper(paper);
5051
}
5152
};
5253

5354
const handleAreaClick = (paper) => {
5455
if (disableClicks) {
5556
return;
5657
}
57-
handleDeselectPaper();
58-
handleZoomIn(paper, "list-area");
58+
handleZoomIn(paper);
5959
};
6060

6161
return (

0 commit comments

Comments
 (0)