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

Use double-click to zoom in on particular offset in LGV, and make ctrl+scroll also zoom in on particular offset #3564

Merged
merged 2 commits into from
Mar 6, 2023
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ exports[`<AddConnectionWidget /> renders 1`] = `
class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-wb57ya-MuiFormControl-root-MuiTextField-root"
>
<label
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-colorPrimary MuiFormLabel-filled MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined css-1sumxir-MuiFormLabel-root-MuiInputLabel-root"
class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-colorPrimary MuiFormLabel-filled MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined css-1jy569b-MuiFormLabel-root-MuiInputLabel-root"
data-shrink="true"
for="mui-1"
id="mui-1-label"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@ const useStyles = makeStyles()({
position: 'relative',
overflow: 'hidden',
},
spacer: {
position: 'relative',
height: 3,
},
})

type LGV = LinearGenomeViewModel

function TracksContainer({
export default observer(function TracksContainer({
children,
model,
}: {
Expand Down Expand Up @@ -60,6 +56,12 @@ function TracksContainer({
ref={ref}
data-testid="trackContainer"
className={classes.tracksContainer}
onClick={event => {
if (event.detail === 2) {
const left = ref.current?.getBoundingClientRect().left || 0
model.zoomTo(model.bpPerPx / 2, event.clientX - left)
}
}}
onMouseDown={event => {
mouseDown1(event)
mouseDown2(event)
Expand Down Expand Up @@ -106,6 +108,4 @@ function TracksContainer({
{children}
</div>
)
}

export default observer(TracksContainer)
})
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,7 @@ exports[`renders one track, one region 1`] = `
style="left: 0%; width: 0%;"
/>
<span
class="MuiSlider-thumb MuiSlider-thumbSizeSmall MuiSlider-thumbColorPrimary css-14gf62f-MuiSlider-thumb"
data-focusvisible="false"
class="MuiSlider-thumb MuiSlider-thumbSizeSmall MuiSlider-thumbColorPrimary MuiSlider-thumb MuiSlider-thumbSizeSmall MuiSlider-thumbColorPrimary css-14gf62f-MuiSlider-thumb"
data-index="0"
style="left: 0%;"
>
Expand Down Expand Up @@ -852,8 +851,7 @@ exports[`renders two tracks, two regions 1`] = `
style="left: 0%; width: 9.774680693120512%;"
/>
<span
class="MuiSlider-thumb MuiSlider-thumbSizeSmall MuiSlider-thumbColorPrimary css-14gf62f-MuiSlider-thumb"
data-focusvisible="false"
class="MuiSlider-thumb MuiSlider-thumbSizeSmall MuiSlider-thumbColorPrimary MuiSlider-thumb MuiSlider-thumbSizeSmall MuiSlider-thumbColorPrimary css-14gf62f-MuiSlider-thumb"
data-index="0"
style="left: 9.774680693120512%;"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ export function useRangeSelect(

export function useWheelScroll(
ref: React.RefObject<HTMLDivElement>,
model: LGV,
model: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ends up with circular reference so duck typed here now

bpPerPx: number
zoomTo: (arg: number, arg2?: number) => void
setScaleFactor: (arg: number) => void
horizontalScroll: (arg: number) => void
},
) {
const delta = useRef(0)
const timeout = useRef<Timer>()
Expand All @@ -266,6 +271,7 @@ export function useWheelScroll(
delta.current > 0
? model.bpPerPx * (1 + delta.current)
: model.bpPerPx / (1 - delta.current),
origEvent.clientX - (curr?.getBoundingClientRect().left || 0),
)
delta.current = 0
}, 300)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ exports[`<JBrowseLinearGenomeView /> renders successfully 1`] = `
style="left: 0%; width: 56.78411120929245%;"
/>
<span
class="MuiSlider-thumb MuiSlider-thumbSizeSmall MuiSlider-thumbColorPrimary css-1kbujg-MuiSlider-thumb"
data-focusvisible="false"
class="MuiSlider-thumb MuiSlider-thumbSizeSmall MuiSlider-thumbColorPrimary MuiSlider-thumb MuiSlider-thumbSizeSmall MuiSlider-thumbColorPrimary css-1kbujg-MuiSlider-thumb"
data-index="0"
style="left: 56.78411120929245%;"
>
Expand Down
Loading