Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
theosanderson committed Feb 15, 2023
1 parent 8d70d3d commit 770d131
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,17 +540,21 @@ const ConfigPanel = ({zoomLevel,setZoomLevel}) => {
// zoom slider
return (
<>
<AiOutlineZoomOut className="inline-block" />
<button className="inline-block" onClick={() => setZoomLevel(
(x) => x-0.1
)}><AiOutlineZoomOut className="inline-block" /></button>
<Slider
value={zoomLevel}
onChange={(x) => setZoomLevel(x)}
min={-6.5}
max={1}
step={0.01}
step={0.001}
style={{ width: 150 }}
className="inline-block mx-5"
/>
<AiOutlineZoomIn className="inline-block" />
<button className="inline-block" onClick={() => setZoomLevel(
(x) => x+0.1
)}><AiOutlineZoomIn className="inline-block" /></button>
</>
);
};
Expand All @@ -564,7 +568,9 @@ const ConfigPanel = ({zoomLevel,setZoomLevel}) => {
function App() {

const [searchPanelOpen, setSearchPanelOpen] = useState(false);
const [zoomLevel, setZoomLevel] = useState(0);
const [zoomLevel, setRawZoomLevel] = useState(0);


// detect ctrl-F and open search panel
useEffect(() => {
const handleKeyDown = (e) => {
Expand Down Expand Up @@ -702,6 +708,26 @@ function App() {


const virtualItems = rowVirtualizer.getVirtualItems();
const [centeredNucleotide, setCenteredNucleotide] = useState(null);

const setZoomLevel = (x) => {
const middleRow = virtualItems[Math.floor(virtualItems.length / 2)].index
const middleRowStart = rowData[middleRow].rowStart;
const middleRowEnd = rowData[middleRow].rowEnd;
const middleRowMiddle = Math.floor((middleRowStart + middleRowEnd) / 2);
setCenteredNucleotide(middleRowMiddle);
console.log("middleRowMiddle", middleRowMiddle);
setRawZoomLevel(x);
}

useEffect(() => {
if (!centeredNucleotide) return;
const row = Math.floor(centeredNucleotide / rowWidth);
rowVirtualizer.scrollToIndex(row, {align:"center",
smoothScroll:false});
setCenteredNucleotide(null);
console.log("scrolling to", centeredNucleotide);
}, [centeredNucleotide,zoomLevel]);


useEffect(() => {
Expand Down

1 comment on commit 770d131

@vercel
Copy link

@vercel vercel bot commented on 770d131 Feb 15, 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.