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

Fixup scroll on wiggle tracks with trackLabels->offset #2821

Merged
merged 3 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import React, { useEffect, useRef } from 'react'
import { Paper, makeStyles } from '@material-ui/core'
import { observer } from 'mobx-react'
import { isAlive } from 'mobx-state-tree'
import { getConf } from '@jbrowse/core/configuration'
import { BaseTrackModel } from '@jbrowse/core/pluggableElementTypes/models'
import { getConf } from '@jbrowse/core/configuration'
import { ResizeHandle } from '@jbrowse/core/ui'
import { useDebouncedCallback } from '@jbrowse/core/util'
import clsx from 'clsx'
import Paper from '@material-ui/core/Paper'
import { makeStyles } from '@material-ui/core/styles'

import { LinearGenomeViewModel, RESIZE_HANDLE_HEIGHT } from '..'
import TrackLabel from './TrackLabel'

const useStyles = makeStyles(theme => ({
root: {},
root: {
margin: 2,
},
resizeHandle: {
height: RESIZE_HANDLE_HEIGHT,
boxSizing: 'border-box',
position: 'relative',
zIndex: 2,
},
overlay: {
Expand All @@ -28,7 +33,6 @@ const useStyles = makeStyles(theme => ({
},
trackLabel: {
zIndex: 3,
margin: theme.spacing(1),
},
trackLabelInline: {
position: 'relative',
Expand All @@ -44,25 +48,45 @@ const useStyles = makeStyles(theme => ({
position: 'relative',
background: 'none',
zIndex: 2,
boxSizing: 'content-box',
},
}))

type LGV = LinearGenomeViewModel

function TrackContainerLabel({
model,
view,
}: {
model: BaseTrackModel
view: LGV
}) {
const classes = useStyles()
const labelStyle =
view.trackLabels === 'overlapping'
? classes.trackLabelOverlap
: classes.trackLabelInline
return view.trackLabels !== 'hidden' ? (
<TrackLabel
track={model}
className={clsx(classes.trackLabel, labelStyle)}
/>
) : null
}

function TrackContainer({
model,
track,
}: {
model: LGV
model: LinearGenomeViewModel
track: BaseTrackModel
}) {
const classes = useStyles()
const display = track.displays[0]
const { id, trackLabels, horizontalScroll, draggingTrackId, moveTrack } =
model
const { horizontalScroll, draggingTrackId, moveTrack } = model
const { height } = display
const trackId = getConf(track, 'trackId')
const ref = useRef<HTMLDivElement>(null)
const ref = useRef(null)

useEffect(() => {
if (ref.current) {
Expand All @@ -86,34 +110,22 @@ function TrackContainer({
const dimmed = draggingTrackId !== undefined && draggingTrackId !== display.id

return (
<div className={classes.root}>
<Paper
variant="outlined"
<Paper className={classes.root} variant="outlined">
<TrackContainerLabel model={track} view={model} />
<div
className={classes.trackRenderingContainer}
style={{ height }}
onScroll={event => {
const target = event.target as HTMLDivElement
display.setScrollTop(target.scrollTop)
}}
onDragEnter={debouncedOnDragEnter}
data-testid={`trackRenderingContainer-${id}-${trackId}`}
data-testid={`trackRenderingContainer-${model.id}-${trackId}`}
role="presentation"
>
{trackLabels !== 'hidden' ? (
<TrackLabel
track={track}
className={clsx(
classes.trackLabel,
trackLabels === 'overlapping'
? classes.trackLabelOverlap
: classes.trackLabelInline,
)}
/>
) : null}
<div ref={ref} style={{ transform: `scaleX(${model.scaleFactor})` }}>
<RenderingComponent
model={display}
blockState={{}}
onHorizontalScroll={horizontalScroll}
/>
</div>
Expand All @@ -129,7 +141,7 @@ function TrackContainer({
<DisplayBlurb model={display} />
</div>
) : null}
</Paper>
</div>
<div
className={classes.overlay}
style={{
Expand All @@ -142,7 +154,7 @@ function TrackContainer({
onDrag={display.resizeHeight}
className={classes.resizeHandle}
/>
</div>
</Paper>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ function TracksContainer({
/>
}
/>
<div className={classes.spacer} />
{children}
</div>
)
Expand Down
Loading