mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-11-21 01:13:37 +08:00
Allow navigating UV editor + timeline with viewport pan key
Closes #1792
This commit is contained in:
parent
f6fb8f68c5
commit
0f05c2784a
@ -245,8 +245,8 @@ const Timeline = {
|
||||
return 1/Math.clamp(Animation.selected ? Animation.selected.snapping : settings.animation_snap.value, 1, 120);
|
||||
},
|
||||
setup() {
|
||||
$('#timeline_body').on('mousedown', e => {
|
||||
if (e.which === 2) {
|
||||
document.getElementById('timeline_body').addEventListener('mousedown', e => {
|
||||
if (e.which === 2 || Keybinds.extra.preview_drag.keybind.isTriggered(e)) {
|
||||
let pos = [e.clientX, e.clientY];
|
||||
let timeline = e.currentTarget;
|
||||
function move(e2) {
|
||||
@ -259,6 +259,9 @@ const Timeline = {
|
||||
function stop(e2) {
|
||||
document.removeEventListener('mousemove', move);
|
||||
document.removeEventListener('mouseup', stop);
|
||||
if (e.which == 3 && Math.pow(e.clientX - pos[0], 2) + Math.pow(e.clientY - pos[1], 2) > 40) {
|
||||
preventContextMenu();
|
||||
}
|
||||
}
|
||||
document.addEventListener('mousemove', move);
|
||||
document.addEventListener('mouseup', stop);
|
||||
@ -583,6 +586,7 @@ const Timeline = {
|
||||
},
|
||||
showMenu(event) {
|
||||
if (event.target.nodeName == 'KEYFRAME' || event.target.parentElement.nodeName == 'KEYFRAME') return;
|
||||
if (Blockbench.hasFlag('no_context_menu')) return;
|
||||
Timeline.menu.open(event, event);
|
||||
},
|
||||
menu: new Menu([
|
||||
|
@ -646,3 +646,10 @@ class Menu {
|
||||
rm_item.menus.remove(scope)
|
||||
}
|
||||
}
|
||||
|
||||
function preventContextMenu() {
|
||||
Blockbench.addFlag('no_context_menu');
|
||||
setTimeout(() => {
|
||||
Blockbench.removeFlag('no_context_menu');
|
||||
}, 20);
|
||||
}
|
||||
|
@ -2275,7 +2275,7 @@ Interface.definePanels(function() {
|
||||
let original_margin = scope.getFrameMargin();
|
||||
let offset = $(scope.$refs.viewport).offset();
|
||||
UVEditor.total_zoom_offset = [6, 6];
|
||||
if (event.which === 2 || (event.touches && !Toolbox.selected.paintTool && event.target.id == 'uv_frame')) {
|
||||
if (event.which === 2 || Keybinds.extra.preview_drag.keybind.isTriggered(event) || (event.touches && !Toolbox.selected.paintTool && event.target.id == 'uv_frame')) {
|
||||
// Drag
|
||||
if (event.touches) {
|
||||
event.clientX = event.touches[0].clientX;
|
||||
@ -2285,8 +2285,8 @@ Interface.definePanels(function() {
|
||||
let margin = this.getFrameMargin();
|
||||
let margin_center = [this.width/2, this.height/2];
|
||||
let original = [
|
||||
viewport.scrollLeft,
|
||||
viewport.scrollTop
|
||||
viewport.scrollLeft - 5,
|
||||
viewport.scrollTop - 5
|
||||
];
|
||||
function dragMouseWheel(e2) {
|
||||
if (e2.touches) {
|
||||
@ -2323,6 +2323,9 @@ Interface.definePanels(function() {
|
||||
function dragMouseWheelStop(e) {
|
||||
removeEventListeners(document, 'mousemove touchmove', dragMouseWheel);
|
||||
removeEventListeners(document, 'mouseup touchend', dragMouseWheelStop);
|
||||
if (e.which == 3 && Math.pow(viewport.scrollLeft - original[0], 2) + Math.pow(viewport.scrollTop - original[1], 2) > 50) {
|
||||
preventContextMenu();
|
||||
}
|
||||
}
|
||||
addEventListeners(document, 'mousemove touchmove', dragMouseWheel);
|
||||
addEventListeners(document, 'mouseup touchend', dragMouseWheelStop);
|
||||
@ -2458,6 +2461,7 @@ Interface.definePanels(function() {
|
||||
},
|
||||
contextMenu(event) {
|
||||
setActivePanel('uv');
|
||||
if (Blockbench.hasFlag('no_context_menu')) return;
|
||||
UVEditor.menu.open(event);
|
||||
},
|
||||
selectTextureMenu(event) {
|
||||
|
Loading…
Reference in New Issue
Block a user