fix resize: use pointer capture to handle drag over iframe
When dragging the resize handle rightward to narrow the panel, the mouse cursor moved over the iframe which captured mouse events. document-level mousemove stopped firing, making narrowing impossible. Fix: replace mouse events with pointer events + setPointerCapture. The handle element captures ALL pointer events during drag regardless of where the cursor moves (over iframe, outside window, etc). Applied to both local_workspace.html and library.html.
This commit is contained in:
@@ -1280,20 +1280,21 @@ function libraryPage() {
|
||||
var handle = document.getElementById('lib-peek-resize-handle');
|
||||
if (!panel || !handle) return;
|
||||
var startX, startWidth, dragging = false;
|
||||
handle.addEventListener('mousedown', function(e) {
|
||||
handle.addEventListener('pointerdown', function(e) {
|
||||
e.preventDefault();
|
||||
handle.setPointerCapture(e.pointerId);
|
||||
startX = e.clientX;
|
||||
startWidth = panel.offsetWidth;
|
||||
dragging = true;
|
||||
document.body.style.userSelect = 'none';
|
||||
});
|
||||
document.addEventListener('mousemove', function(e) {
|
||||
handle.addEventListener('pointermove', function(e) {
|
||||
if (!dragging) return;
|
||||
var deltaX = startX - e.clientX;
|
||||
var newWidth = Math.max(300, Math.min(window.innerWidth * 0.9, startWidth + deltaX));
|
||||
panel.style.width = newWidth + 'px';
|
||||
});
|
||||
document.addEventListener('mouseup', function(e) {
|
||||
handle.addEventListener('pointerup', function(e) {
|
||||
if (!dragging) return;
|
||||
document.body.style.userSelect = '';
|
||||
var moved = Math.abs(e.clientX - startX);
|
||||
@@ -1303,6 +1304,7 @@ function libraryPage() {
|
||||
}
|
||||
dragging = false;
|
||||
try { localStorage.setItem('fd_peek_width', panel.style.width); } catch(ex) {}
|
||||
handle.releasePointerCapture(e.pointerId);
|
||||
});
|
||||
try {
|
||||
var saved = localStorage.getItem('fd_peek_width');
|
||||
|
||||
@@ -639,20 +639,21 @@ window._wsInitData = (function() {
|
||||
var handle = document.getElementById('ws-preview-resize-handle');
|
||||
if (!panel || !handle) return;
|
||||
var startX, startWidth, dragging = false;
|
||||
handle.addEventListener('mousedown', function(e) {
|
||||
handle.addEventListener('pointerdown', function(e) {
|
||||
e.preventDefault();
|
||||
handle.setPointerCapture(e.pointerId);
|
||||
startX = e.clientX;
|
||||
startWidth = panel.offsetWidth;
|
||||
dragging = true;
|
||||
document.body.style.userSelect = 'none';
|
||||
});
|
||||
document.addEventListener('mousemove', function(e) {
|
||||
handle.addEventListener('pointermove', function(e) {
|
||||
if (!dragging) return;
|
||||
var deltaX = startX - e.clientX;
|
||||
var newWidth = Math.max(300, Math.min(window.innerWidth * 0.9, startWidth + deltaX));
|
||||
panel.style.width = newWidth + 'px';
|
||||
});
|
||||
document.addEventListener('mouseup', function(e) {
|
||||
handle.addEventListener('pointerup', function(e) {
|
||||
if (!dragging) return;
|
||||
document.body.style.userSelect = '';
|
||||
var moved = Math.abs(e.clientX - startX);
|
||||
@@ -661,6 +662,7 @@ window._wsInitData = (function() {
|
||||
}
|
||||
dragging = false;
|
||||
try { localStorage.setItem('fd_peek_width', panel.style.width); } catch(ex) {}
|
||||
handle.releasePointerCapture(e.pointerId);
|
||||
});
|
||||
try {
|
||||
var saved = localStorage.getItem('fd_peek_width');
|
||||
|
||||
Reference in New Issue
Block a user