mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-02-17 16:20:13 +08:00
Outliner automatically scroll when dragging
This commit is contained in:
parent
c1be9dcc8c
commit
77d06467de
@ -1073,6 +1073,7 @@ Interface.definePanels(function() {
|
||||
Vue.component('vue-tree-item', VueTreeItem);
|
||||
|
||||
function eventTargetToNode(target) {
|
||||
if (!target) return [];
|
||||
let target_node = target;
|
||||
let i = 0;
|
||||
while (target_node && target_node.classList && !target_node.classList.contains('outliner_node')) {
|
||||
@ -1217,6 +1218,18 @@ Interface.definePanels(function() {
|
||||
let drop_target, drop_target_node, order;
|
||||
let last_event = e1;
|
||||
|
||||
// scrolling
|
||||
let list = document.getElementById('cubes_list');
|
||||
let list_offset = $(list).offset();
|
||||
let scrollInterval = function() {
|
||||
if (!active) return;
|
||||
if (mouse_pos.y < list_offset.top) {
|
||||
list.scrollTop += (mouse_pos.y - list_offset.top) / 7 - 3;
|
||||
} else if (mouse_pos.y > list_offset.top + list.clientHeight) {
|
||||
list.scrollTop += (mouse_pos.y - (list_offset.top + list.clientHeight)) / 6 + 3;
|
||||
}
|
||||
}
|
||||
|
||||
function move(e2) {
|
||||
convertTouchEvent(e2);
|
||||
let offset = [
|
||||
@ -1253,6 +1266,8 @@ Interface.definePanels(function() {
|
||||
helper.append(counter);
|
||||
}
|
||||
document.body.append(helper);
|
||||
|
||||
setInterval(scrollInterval, 1000/60)
|
||||
}
|
||||
helper.style.left = `${e2.clientX}px`;
|
||||
helper.style.top = `${e2.clientY}px`;
|
||||
@ -1277,6 +1292,7 @@ Interface.definePanels(function() {
|
||||
}
|
||||
function off(e2) {
|
||||
if (helper) helper.remove();
|
||||
clearInterval(scrollInterval);
|
||||
removeEventListeners(document, 'mousemove touchmove', move);
|
||||
removeEventListeners(document, 'mouseup touchend', off);
|
||||
$('.drag_hover').removeClass('drag_hover');
|
||||
|
Loading…
Reference in New Issue
Block a user