Skip to content

Commit

Permalink
fixminimap
Browse files Browse the repository at this point in the history
  • Loading branch information
theosanderson committed Sep 13, 2023
1 parent 8dd1ec6 commit 5037050
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
9 changes: 8 additions & 1 deletion taxonium_component/src/Deck.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ function Deck({
deckRef,
jbrowseRef,
setAdditionalColorMapping,
mouseDownIsMinimap,
setMouseDownIsMinimap

}) {
const zoomReset = view.zoomReset;
const snapshot = useSnapshot(deckRef);
Expand Down Expand Up @@ -75,7 +78,6 @@ function Deck({
);
const [treenomeReferenceInfo, setTreenomeReferenceInfo] = useState(null);

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

const mouseDownPos = useRef();

Expand Down Expand Up @@ -109,6 +111,9 @@ function Deck({
y: event.nativeEvent.offsetY,
radius: 10,
});
if (event._reactName === "onPointerUp") {
setMouseDownIsMinimap(false);
}

if (event._reactName === "onPointerDown") {
if (pickInfo && pickInfo.viewport.id === "minimap") {
Expand All @@ -134,8 +139,10 @@ function Deck({
pickInfo.viewport.id === "minimap" &&
mouseDownIsMinimap
) {

onViewStateChange({
oldViewState: viewState,
specialMinimap:true,
viewState: {
...viewState,
target: [
Expand Down
5 changes: 4 additions & 1 deletion taxonium_component/src/Taxonium.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ 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 +195,8 @@ function Taxonium({
isCurrentlyOutsideBounds={isCurrentlyOutsideBounds}
treenomeState={treenomeState}
deckRef={deckRef}
mouseDownIsMinimap={mouseDownIsMinimap}
setMouseDownIsMinimap={setMouseDownIsMinimap}
jbrowseRef={jbrowseRef}
setAdditionalColorMapping={setAdditionalColorMapping}
/>
Expand Down
10 changes: 9 additions & 1 deletion taxonium_component/src/hooks/useView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ 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,7 +232,10 @@ const useView = ({ settings, deckSize, deckRef, jbrowseRef }) => {
oldViewState,
basicTarget,
overrideZoomAxis,
specialMinimap

}) => {

if (!deckSize) {
return;
}
Expand All @@ -248,6 +251,11 @@ 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

0 comments on commit 5037050

Please sign in to comment.