()
| 745 | } |
| 746 | |
| 747 | function initSidebarResize() { |
| 748 | const sidebar = document.getElementById('sidebar'); |
| 749 | const resizeHandle = document.getElementById('sidebar-resize-handle'); |
| 750 | if (!sidebar || !resizeHandle) return; |
| 751 | |
| 752 | let isResizing = false; |
| 753 | let startX = 0; |
| 754 | let startWidth = 0; |
| 755 | const minWidth = 200; |
| 756 | const maxWidth = 600; |
| 757 | |
| 758 | resizeHandle.addEventListener('mousedown', function(e) { |
| 759 | isResizing = true; |
| 760 | startX = e.clientX; |
| 761 | startWidth = sidebar.offsetWidth; |
| 762 | resizeHandle.classList.add('resizing'); |
| 763 | document.body.classList.add('resizing-sidebar'); |
| 764 | e.preventDefault(); |
| 765 | }); |
| 766 | |
| 767 | document.addEventListener('mousemove', function(e) { |
| 768 | if (!isResizing) return; |
| 769 | |
| 770 | const deltaX = e.clientX - startX; |
| 771 | const newWidth = Math.min(Math.max(startWidth + deltaX, minWidth), maxWidth); |
| 772 | sidebar.style.width = newWidth + 'px'; |
| 773 | e.preventDefault(); |
| 774 | }); |
| 775 | |
| 776 | document.addEventListener('mouseup', function() { |
| 777 | if (isResizing) { |
| 778 | isResizing = false; |
| 779 | resizeHandle.classList.remove('resizing'); |
| 780 | document.body.classList.remove('resizing-sidebar'); |
| 781 | |
| 782 | // Save the new width |
| 783 | const width = sidebar.offsetWidth; |
| 784 | localStorage.setItem('flamegraph-sidebar-width', width); |
| 785 | |
| 786 | // Resize chart after sidebar resize |
| 787 | setTimeout(() => { |
| 788 | resizeChart(); |
| 789 | }, 10); |
| 790 | } |
| 791 | }); |
| 792 | } |
| 793 | |
| 794 | // ============================================================================ |
| 795 | // Thread Stats |
no test coverage detected
searching dependent graphs…