Add resizable thumbnail sidebar to EnvelopeViewer
Introduced a resizable splitter for the PDF thumbnail sidebar, allowing users to dynamically adjust its width. Added `_thumbnailWidth` property with min/max constraints and implemented mouse event handlers (`OnSplitterMouseDown`, `OnSplitterMouseMove`, `OnSplitterMouseUp`) to manage resizing. Integrated JavaScript interop to attach/detach resize event listeners and save user preferences to `localStorage`. Updated `pdf-viewer.js` to handle resizing state and cleanup. Styled the splitter in `envelope-viewer.css` with hover/active states and ensured smooth interaction. Persisted thumbnail width across sessions and added error handling for `localStorage`. Enhanced user experience with intuitive resizing and improved UI flexibility.
This commit is contained in:
@@ -289,6 +289,48 @@ window.pdfViewer = {
|
||||
this.wheelEventAttached = false;
|
||||
this.dotNetReference = null;
|
||||
}
|
||||
this.detachResizeListeners();
|
||||
},
|
||||
|
||||
// Resizable splitter functionality
|
||||
isResizing: false,
|
||||
resizeMouseMoveHandler: null,
|
||||
resizeMouseUpHandler: null,
|
||||
|
||||
attachResizeListeners(dotNetRef) {
|
||||
this.dotNetReference = dotNetRef;
|
||||
|
||||
this.resizeMouseMoveHandler = (e) => {
|
||||
if (this.isResizing && this.dotNetReference) {
|
||||
this.dotNetReference.invokeMethodAsync('OnSplitterMouseMove', e.clientX);
|
||||
}
|
||||
};
|
||||
|
||||
this.resizeMouseUpHandler = () => {
|
||||
if (this.isResizing && this.dotNetReference) {
|
||||
this.isResizing = false;
|
||||
this.dotNetReference.invokeMethodAsync('OnSplitterMouseUp');
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener('mousemove', this.resizeMouseMoveHandler);
|
||||
document.addEventListener('mouseup', this.resizeMouseUpHandler);
|
||||
},
|
||||
|
||||
detachResizeListeners() {
|
||||
if (this.resizeMouseMoveHandler) {
|
||||
document.removeEventListener('mousemove', this.resizeMouseMoveHandler);
|
||||
this.resizeMouseMoveHandler = null;
|
||||
}
|
||||
if (this.resizeMouseUpHandler) {
|
||||
document.removeEventListener('mouseup', this.resizeMouseUpHandler);
|
||||
this.resizeMouseUpHandler = null;
|
||||
}
|
||||
this.isResizing = false;
|
||||
},
|
||||
|
||||
startResize() {
|
||||
this.isResizing = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user