Skip to content

Commit

Permalink
Merge pull request #522 from theosanderson/fixminimap
Browse files Browse the repository at this point in the history
Fix issue where you could not pan in the minimap
  • Loading branch information
theosanderson authored Sep 13, 2023
2 parents 8dd1ec6 + 727ebfe commit d7af6f7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
8 changes: 6 additions & 2 deletions taxonium_component/src/Deck.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ function Deck({
deckRef,
jbrowseRef,
setAdditionalColorMapping,
mouseDownIsMinimap,
setMouseDownIsMinimap,
}) {
const zoomReset = view.zoomReset;
const snapshot = useSnapshot(deckRef);
Expand Down Expand Up @@ -75,12 +77,13 @@ function Deck({
);
const [treenomeReferenceInfo, setTreenomeReferenceInfo] = useState(null);

const [mouseDownIsMinimap, setMouseDownIsMinimap] = useState(false);

const mouseDownPos = useRef();

const onClickOrMouseMove = useCallback(
(event) => {
if (event._reactName === "onClick") {
setMouseDownIsMinimap(false);
}
if (event.buttons === 0 && event._reactName === "onPointerMove") {
return false;
}
Expand Down Expand Up @@ -136,6 +139,7 @@ function Deck({
) {
onViewStateChange({
oldViewState: viewState,
specialMinimap: true,
viewState: {
...viewState,
target: [
Expand Down
11 changes: 10 additions & 1 deletion taxonium_component/src/Taxonium.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,17 @@ function Taxonium({

const deckRef = useRef();
const jbrowseRef = useRef();
const [mouseDownIsMinimap, setMouseDownIsMinimap] = useState(false);

const [deckSize, setDeckSize] = useState(null);
const settings = useSettings({ query, updateQuery });
const view = useView({ settings, deckSize, deckRef, jbrowseRef });
const view = useView({
settings,
deckSize,
deckRef,
jbrowseRef,
mouseDownIsMinimap,
});

const url_on_fail = URL_ON_FAIL ? URL_ON_FAIL : null;

Expand Down Expand Up @@ -194,6 +201,8 @@ function Taxonium({
isCurrentlyOutsideBounds={isCurrentlyOutsideBounds}
treenomeState={treenomeState}
deckRef={deckRef}
mouseDownIsMinimap={mouseDownIsMinimap}
setMouseDownIsMinimap={setMouseDownIsMinimap}
jbrowseRef={jbrowseRef}
setAdditionalColorMapping={setAdditionalColorMapping}
/>
Expand Down
13 changes: 12 additions & 1 deletion taxonium_component/src/hooks/useView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ class MyOrthographicController extends OrthographicController {
}
}

const useView = ({ settings, deckSize, deckRef, jbrowseRef }) => {
const useView = ({
settings,
deckSize,
deckRef,
jbrowseRef,
mouseDownIsMinimap,
}) => {
const [zoomAxis, setZoomAxis] = useState("Y");
const [xzoom, setXzoom] = useState(window.screen.width < 600 ? -1 : 0);
globalSetZoomAxis = setZoomAxis;
Expand Down Expand Up @@ -232,6 +238,7 @@ const useView = ({ settings, deckSize, deckRef, jbrowseRef }) => {
oldViewState,
basicTarget,
overrideZoomAxis,
specialMinimap,
}) => {
if (!deckSize) {
return;
Expand All @@ -248,6 +255,10 @@ const useView = ({ settings, deckSize, deckRef, jbrowseRef }) => {
const newScaleY = 2 ** newViewState.zoom;
// eslint-disable-line no-unused-vars

if (mouseDownIsMinimap && !specialMinimap && oldScaleY === newScaleY) {
return;
}

let newScaleX = 2 ** xzoom;
if (basicTarget) {
newViewState.target[0] =
Expand Down

1 comment on commit d7af6f7

@vercel
Copy link

@vercel vercel bot commented on d7af6f7 Sep 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.