Fix Cursor Grab while panning (#4957)

Co-authored-by: John Hill <john.c.hill@nasa.gov>
This commit is contained in:
Syed Tasnim Ahmed 2022-03-25 14:07:05 -04:00 committed by GitHub
parent 824a597825
commit 2b599a7ff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -76,6 +76,9 @@
<div <div
ref="chartContainer" ref="chartContainer"
class="gl-plot-chart-wrapper" class="gl-plot-chart-wrapper"
:class="[
{ 'alt-pressed': altPressed },
]"
> >
<mct-chart <mct-chart
:rectangles="rectangles" :rectangles="rectangles"
@ -230,6 +233,7 @@ export default {
}, },
data() { data() {
return { return {
altPressed: false,
highlights: [], highlights: [],
lockHighlightPoint: false, lockHighlightPoint: false,
tickWidth: 0, tickWidth: 0,
@ -268,6 +272,8 @@ export default {
} }
}, },
mounted() { mounted() {
document.addEventListener('keydown', this.handleKeyDown);
document.addEventListener('keyup', this.handleKeyUp);
eventHelpers.extend(this); eventHelpers.extend(this);
this.updateRealTime = this.updateRealTime.bind(this); this.updateRealTime = this.updateRealTime.bind(this);
this.updateDisplayBounds = this.updateDisplayBounds.bind(this); this.updateDisplayBounds = this.updateDisplayBounds.bind(this);
@ -299,9 +305,21 @@ export default {
}, },
beforeDestroy() { beforeDestroy() {
document.removeEventListener('keydown', this.handleKeyDown);
document.removeEventListener('keyup', this.handleKeyUp);
this.destroy(); this.destroy();
}, },
methods: { methods: {
handleKeyDown(event) {
if (event.key === 'Alt') {
this.altPressed = true;
}
},
handleKeyUp(event) {
if (event.key === 'Alt') {
this.altPressed = false;
}
},
setTimeContext() { setTimeContext() {
this.stopFollowingTimeContext(); this.stopFollowingTimeContext();

View File

@ -160,6 +160,10 @@ mct-plot {
bottom: 0; bottom: 0;
left: 0; left: 0;
} }
.alt-pressed {
// When alt is being pressed and user is hovering over the plot, set the cursor
@include cursorGrab();
}
.gl-plot-axis-area.gl-plot-x { .gl-plot-axis-area.gl-plot-x {
top: auto; top: auto;