Fix graph editor box select selects graph on mouseup

This commit is contained in:
JannisX11 2023-08-26 19:49:25 +02:00
parent ac9b153850
commit 0dfb6d053b
2 changed files with 27 additions and 14 deletions

View File

@ -96,16 +96,21 @@ const Timeline = {
e.clientX - R.panel_offset[0],
e.clientY - R.panel_offset[1],
]
R.start_event = e;
if (e.shiftKey || Pressing.overrides.shift) {
Timeline.selector.selected_before = Timeline.selected.slice();
}
R.selecting = true;
$('#timeline_selector').show()
Timeline.selector.move(e)
},
move(e) {
var R = Timeline.selector;
if (!R.selecting) return;
if (!R.selecting) {
if (Math.pow(R.start_event.clientX - mouse_pos.x, 2) + Math.pow(R.start_event.clientY - mouse_pos.y, 2) > 20) {
R.selecting = true;
$('#timeline_selector').show();
} else {
return;
}
}
//CSS
var offset = $('#timeline_body_inner').offset();
R.panel_offset = [
@ -186,19 +191,27 @@ const Timeline = {
updateKeyframeSelection()
},
end(e) {
if (!Timeline.selector.selecting) return false;
e.stopPropagation();
document.removeEventListener('mousemove', Timeline.selector.move);
clearInterval(Timeline.selector.interval);
document.removeEventListener('mouseup', Timeline.selector.end);
updateKeyframeSelection()
Timeline.selector.selected_before.empty();
Timeline.selector.selecting = false;
$('#timeline_selector')
.css('width', 0)
.css('height', 0)
.hide()
if (!Timeline.selector.selecting) {
if (settings.canvas_unselect.value) {
Timeline.selected.empty();
updateKeyframeSelection();
}
Timeline.vue.clickGraphEditor(e);
return false;
} else {
updateKeyframeSelection()
Timeline.selector.selected_before.empty();
Timeline.selector.selecting = false;
$('#timeline_selector')
.css('width', 0)
.css('height', 0)
.hide();
}
},
},
setTime(seconds, editing) {
@ -1515,7 +1528,7 @@ Interface.definePanels(() => {
<div id="timeline_empty_head" class="channel_head" v-bind:style="{left: scroll_left+'px', width: head_width+'px'}">
</div>
<div id="timeline_selector" class="selection_rectangle"></div>
<div id="timeline_graph_editor" ref="graph_editor" v-if="graph_editor_open" :style="{left: head_width + 'px', top: scroll_top + 'px'}" @click.stop="clickGraphEditor($event)">
<div id="timeline_graph_editor" ref="graph_editor" v-if="graph_editor_open" :style="{left: head_width + 'px', top: scroll_top + 'px'}">
<svg :style="{'margin-left': clamp(scroll_left, 9, Infinity) + 'px'}">
<path :d="zero_line" style="stroke: var(--color-grid);"></path>
<path :d="one_line" style="stroke: var(--color-grid); stroke-dasharray: 6;" v-if="graph_editor_channel == 'scale'"></path>

View File

@ -880,7 +880,7 @@
"settings.local_move": "Move on Relative Axes",
"settings.local_move.desc": "Move rotated elements on their own axes if possible",
"settings.canvas_unselect": "Unselect when Clicking Background",
"settings.canvas_unselect.desc": "Unselects all elements when clicking on the background behind the model",
"settings.canvas_unselect.desc": "Unselects all elements when clicking on the background behind the model or in the timeline",
"settings.double_click_switch_tools": "Switch Tools on Double Click",
"settings.double_click_switch_tools.desc": "Double click the viewport to switch between tools",
"settings.highlight_cubes": "Highlight Elements",