Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll both panels of the linear synteny view when side scrolling the middle panel #4110

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useCallback } from 'react'
import React, { useState, useCallback, useRef } from 'react'
import { observer } from 'mobx-react'
import {
assembleLocString,
Expand All @@ -12,13 +12,16 @@ import SyntenyTooltip from './SyntenyTooltip'
import { LinearSyntenyDisplayModel } from '../model'
import { getId, MAX_COLOR_RANGE } from '../drawSynteny'
import { LinearSyntenyViewModel } from '../../LinearSyntenyView/model'
import { transaction } from 'mobx'

const LinearSyntenyRendering = observer(function ({
model,
}: {
model: LinearSyntenyDisplayModel
}) {
const highResolutionScaling = 1
const xOffset = useRef(0)
const currScrollFrame = useRef<number>()
const view = getContainingView(model) as LinearSyntenyViewModel
const height = view.middleComparativeHeight
const width = view.width
Expand Down Expand Up @@ -59,6 +62,22 @@ const LinearSyntenyRendering = observer(function ({
/>
<canvas
ref={k2}
onWheel={event => {
if (Math.abs(event.deltaY) < Math.abs(event.deltaX)) {
xOffset.current += event.deltaX
}
if (currScrollFrame.current === undefined) {
currScrollFrame.current = requestAnimationFrame(() => {
transaction(() => {
for (const v of view.views) {
v.horizontalScroll(xOffset.current)
}
xOffset.current = 0
currScrollFrame.current = undefined
})
})
}
}}
onMouseMove={event => {
const ref1 = model.clickMapCanvas
const ref2 = model.cigarClickMapCanvas
Expand Down