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

View File

@ -160,6 +160,10 @@ mct-plot {
bottom: 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 {
top: auto;