mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-01-18 04:10:11 +08:00
support resizable columns for touch (tablets)
This commit is contained in:
parent
1da05297ea
commit
85abbbb8fa
@ -65,21 +65,31 @@
|
|||||||
resizeHandle.classList.add('resize-handle');
|
resizeHandle.classList.add('resize-handle');
|
||||||
parent.insertBefore(resizeHandle, rightCol);
|
parent.insertBefore(resizeHandle, rightCol);
|
||||||
|
|
||||||
resizeHandle.addEventListener('mousedown', (evt) => {
|
['mousedown', 'touchstart'].forEach((eventType) => {
|
||||||
if (evt.button !== 0) return;
|
resizeHandle.addEventListener(eventType, (evt) => {
|
||||||
|
if (eventType.startsWith('mouse')){
|
||||||
|
if (evt.button !== 0) return;
|
||||||
|
} else {
|
||||||
|
if (evt.changedTouches.length !== 1) return;
|
||||||
|
}
|
||||||
|
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
|
|
||||||
document.body.classList.add('resizing');
|
document.body.classList.add('resizing');
|
||||||
|
|
||||||
R.tracking = true;
|
R.tracking = true;
|
||||||
R.parent = parent;
|
R.parent = parent;
|
||||||
R.parentWidth = parent.offsetWidth;
|
R.parentWidth = parent.offsetWidth;
|
||||||
R.handle = resizeHandle;
|
R.handle = resizeHandle;
|
||||||
R.leftCol = leftCol;
|
R.leftCol = leftCol;
|
||||||
R.leftColStartWidth = leftCol.offsetWidth;
|
R.leftColStartWidth = leftCol.offsetWidth;
|
||||||
R.screenX = evt.screenX;
|
if (eventType.startsWith('mouse')){
|
||||||
|
R.screenX = evt.screenX;
|
||||||
|
} else {
|
||||||
|
R.screenX = evt.changedTouches[0].screenX;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
resizeHandle.addEventListener('dblclick', (evt) => {
|
resizeHandle.addEventListener('dblclick', (evt) => {
|
||||||
@ -92,30 +102,46 @@
|
|||||||
afterResize(parent);
|
afterResize(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('mousemove', (evt) => {
|
['mousemove', 'touchmove'].forEach((eventType) => {
|
||||||
if (evt.button !== 0) return;
|
window.addEventListener(eventType, (evt) => {
|
||||||
|
if (eventType.startsWith('mouse')){
|
||||||
|
if (evt.button !== 0) return;
|
||||||
|
} else {
|
||||||
|
if (evt.changedTouches.length !== 1) return;
|
||||||
|
}
|
||||||
|
|
||||||
if (R.tracking) {
|
if (R.tracking) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
|
|
||||||
const delta = R.screenX - evt.screenX;
|
if (eventType.startsWith('mouse')){
|
||||||
const leftColWidth = Math.max(Math.min(R.leftColStartWidth - delta, R.parent.offsetWidth - GRADIO_MIN_WIDTH - PAD), GRADIO_MIN_WIDTH);
|
var delta = R.screenX - evt.screenX;
|
||||||
setLeftColGridTemplate(R.parent, leftColWidth);
|
} else {
|
||||||
}
|
var delta = R.screenX - evt.changedTouches[0].screenX;
|
||||||
|
}
|
||||||
|
const leftColWidth = Math.max(Math.min(R.leftColStartWidth - delta, R.parent.offsetWidth - GRADIO_MIN_WIDTH - PAD), GRADIO_MIN_WIDTH);
|
||||||
|
setLeftColGridTemplate(R.parent, leftColWidth);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('mouseup', (evt) => {
|
['mouseup', 'touchend'].forEach((eventType) => {
|
||||||
if (evt.button !== 0) return;
|
window.addEventListener(eventType, (evt) => {
|
||||||
|
if (eventType.startsWith('mouse')){
|
||||||
|
if (evt.button !== 0) return;
|
||||||
|
} else {
|
||||||
|
if (evt.changedTouches.length !== 1) return;
|
||||||
|
}
|
||||||
|
|
||||||
if (R.tracking) {
|
if (R.tracking) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
|
|
||||||
R.tracking = false;
|
R.tracking = false;
|
||||||
|
|
||||||
document.body.classList.remove('resizing');
|
document.body.classList.remove('resizing');
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user