mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-11-27 04:21:46 +08:00
Make zoom keys work in preview and timeline
This commit is contained in:
parent
395b94f662
commit
a0104271cb
@ -268,7 +268,7 @@ const Timeline = {
|
||||
|
||||
let offset = e.clientX - $('#timeline_time').offset().left;
|
||||
let time = Math.clamp(offset / Timeline.vue._data.size, 0, Infinity);
|
||||
if (!e.ctrlKey) time = Timeline.snapTime(time);
|
||||
if (!e.ctrlOrCmd) time = Timeline.snapTime(time);
|
||||
Timeline.setTime(time);
|
||||
Animator.preview();
|
||||
}
|
||||
@ -279,7 +279,7 @@ const Timeline = {
|
||||
convertTouchEvent(e);
|
||||
let offset = e.clientX - $('#timeline_time').offset().left;
|
||||
let time = Math.clamp(offset / Timeline.vue._data.size, 0, Infinity);
|
||||
if (!e.ctrlKey) time = Timeline.snapTime(time);
|
||||
if (!e.ctrlOrCmd) time = Timeline.snapTime(time);
|
||||
if (Timeline.time != time) {
|
||||
Timeline.setTime(time)
|
||||
Animator.preview()
|
||||
@ -374,6 +374,7 @@ const Timeline = {
|
||||
|
||||
let offset = $('#timeline_body_inner').offset()
|
||||
let offsetX = event.clientX - offset.left - Timeline.vue._data.head_width;
|
||||
console.log(offsetX)
|
||||
|
||||
var zoom = 1 - event.deltaY/600
|
||||
let original_size = Timeline.vue._data.size
|
||||
@ -553,6 +554,11 @@ const Timeline = {
|
||||
menu: new Menu([
|
||||
'paste',
|
||||
'_',
|
||||
{name: 'menu.view.zoom', id: 'zoom', condition: isApp, icon: 'search', children: [
|
||||
'zoom_in',
|
||||
'zoom_out',
|
||||
'zoom_reset'
|
||||
]},
|
||||
'select_all',
|
||||
'bring_up_all_animations',
|
||||
'fold_all_animations',
|
||||
@ -747,7 +753,7 @@ onVueSetup(function() {
|
||||
dragging_restriction;
|
||||
originalValue;
|
||||
previousValue = 0;
|
||||
time_stretching = !Timeline.vue.graph_editor_open && e1.ctrlKey && Timeline.selected.length > 1;
|
||||
time_stretching = !Timeline.vue.graph_editor_open && e1.ctrlOrCmd && Timeline.selected.length > 1;
|
||||
values_changed = false;
|
||||
|
||||
if (!clicked.selected && !e1.shiftKey && Timeline.selected.length != 0) {
|
||||
|
@ -466,11 +466,11 @@ class NumSlider extends Widget {
|
||||
} else {
|
||||
this.interval = function(event) {
|
||||
event = event||0;
|
||||
if (!event.shiftKey && !event.ctrlKey) {
|
||||
if (!event.shiftKey && !event.ctrlOrCmd) {
|
||||
return 1
|
||||
} else if (event.ctrlKey && event.shiftKey) {
|
||||
} else if (event.ctrlOrCmd && event.shiftKey) {
|
||||
return 0.025
|
||||
} else if (event.ctrlKey) {
|
||||
} else if (event.ctrlOrCmd) {
|
||||
return 0.1
|
||||
} else if (event.shiftKey) {
|
||||
return 0.25
|
||||
|
@ -444,17 +444,30 @@ function setZoomLevel(mode) {
|
||||
zoom = limitNumber(zoom, 1, 4)
|
||||
main_uv.setZoom(zoom)
|
||||
|
||||
}
|
||||
/* else if (isApp) {
|
||||
switch (mode) {
|
||||
case 'in': Prop.zoom += 5; break;
|
||||
case 'out': Prop.zoom -= 5; break;
|
||||
case 'reset': Prop.zoom = 100; break;
|
||||
} else if (Prop.active_panel == 'timeline') {
|
||||
|
||||
let body = document.getElementById('timeline_body');
|
||||
let offsetX = Timeline.vue.scroll_left + (body.clientWidth - Timeline.vue.head_width) / 2;
|
||||
|
||||
if (mode == 'reset') {
|
||||
let original_size = Timeline.vue._data.size
|
||||
Timeline.vue._data.size = 200;
|
||||
|
||||
body.scrollLeft += (Timeline.vue._data.size - original_size) * (offsetX / original_size)
|
||||
} else {
|
||||
let zoom = mode == 'in' ? 1.2 : 0.8;
|
||||
let original_size = Timeline.vue._data.size
|
||||
let updated_size = limitNumber(Timeline.vue._data.size * zoom, 10, 1000)
|
||||
Timeline.vue._data.size = updated_size;
|
||||
|
||||
body.scrollLeft += (updated_size - original_size) * (offsetX / original_size)
|
||||
}
|
||||
var level = (Prop.zoom - 100) / 12
|
||||
currentwindow.webContents.setZoomLevel(level)
|
||||
resizeWindow()
|
||||
}*/
|
||||
} else {
|
||||
switch (mode) {
|
||||
case 'in': Preview.selected.controls.dollyIn(1.16); break;
|
||||
case 'out': Preview.selected.controls.dollyOut(1.16); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Dialogs
|
||||
|
@ -584,7 +584,7 @@ function dropOutlinerObjects(item, target, event, order) {
|
||||
}
|
||||
if (event.altKey) {
|
||||
Undo.initEdit({elements: [], outliner: true, selection: true})
|
||||
selected.length = 0
|
||||
selected.empty();
|
||||
} else {
|
||||
Undo.initEdit({outliner: true, selection: true})
|
||||
var updatePosRecursive = function(item) {
|
||||
@ -622,7 +622,7 @@ function dropOutlinerObjects(item, target, event, order) {
|
||||
} else {
|
||||
var cube = item.duplicate()
|
||||
place(cube)
|
||||
selected.push(cube)
|
||||
selected.safePush(cube)
|
||||
}
|
||||
} else {
|
||||
place(item)
|
||||
|
@ -376,6 +376,9 @@ THREE.OrbitControls = function ( object, preview ) {
|
||||
|
||||
}
|
||||
|
||||
this.dollyIn = dollyIn;
|
||||
this.dollyOut = dollyOut;
|
||||
|
||||
// event callbacks - update the object state
|
||||
|
||||
function handleMouseDownRotate( event ) {
|
||||
|
@ -729,7 +729,7 @@ BARS.defineActions(function() {
|
||||
},
|
||||
getInterval(e) {
|
||||
if (e.shiftKey) return 12.5;
|
||||
if (e.ctrlKey) return 1;
|
||||
if (e.ctrlOrCmd) return 1;
|
||||
return 4
|
||||
},
|
||||
get: function() {
|
||||
@ -749,7 +749,7 @@ BARS.defineActions(function() {
|
||||
},
|
||||
getInterval(e) {
|
||||
if (e.shiftKey) return 10;
|
||||
if (e.ctrlKey) return 1;
|
||||
if (e.ctrlOrCmd) return 1;
|
||||
return 2
|
||||
},
|
||||
get: function() {
|
||||
@ -769,7 +769,7 @@ BARS.defineActions(function() {
|
||||
},
|
||||
getInterval(e) {
|
||||
if (e.shiftKey) return 10;
|
||||
if (e.ctrlKey) return 1;
|
||||
if (e.ctrlOrCmd) return 1;
|
||||
return 2
|
||||
},
|
||||
get: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user