Skip to content

Commit

Permalink
Fix ability to click and drag overview scale bar dragging right to le…
Browse files Browse the repository at this point in the history
…ft (#3151)

Fix ability to click and drag overview scale bar dragging right to left.
Fixes #3123
  • Loading branch information
cmdcolin committed Aug 19, 2022
1 parent 1b67991 commit 71c7a79
Showing 1 changed file with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import React, { useRef, useEffect, useState } from 'react'
import { Popover, Tooltip, Typography, alpha } from '@mui/material'
import { makeStyles } from 'tss-react/mui'
import { getSession, stringify } from '@jbrowse/core/util'
import { observer, PropTypes as MobxPropTypes } from 'mobx-react'
import ReactPropTypes from 'prop-types'
import { observer } from 'mobx-react'
import { Base1DViewModel } from '@jbrowse/core/util/Base1DViewModel'
import { LinearGenomeViewModel, HEADER_OVERVIEW_HEIGHT } from '..'

Expand Down Expand Up @@ -123,9 +122,11 @@ function OverviewRubberBand({
// click and drag
if (startX !== undefined && currentX !== undefined) {
if (Math.abs(currentX - startX) > 3) {
const left = Math.min(startX, currentX)
const right = Math.max(startX, currentX)
model.moveTo(
overview.pxToBp(startX - cytobandOffset),
overview.pxToBp(currentX - cytobandOffset),
overview.pxToBp(left - cytobandOffset),
overview.pxToBp(right - cytobandOffset),
)
}
}
Expand Down Expand Up @@ -306,14 +307,4 @@ function OverviewRubberBand({
)
}

OverviewRubberBand.propTypes = {
model: MobxPropTypes.objectOrObservableObject.isRequired,
overview: MobxPropTypes.objectOrObservableObject.isRequired,
ControlComponent: ReactPropTypes.node,
}

OverviewRubberBand.defaultProps = {
ControlComponent: <div />,
}

export default observer(OverviewRubberBand)

0 comments on commit 71c7a79

Please sign in to comment.