From c31d16f22a85941f3e593c02f1ebe53b47621969 Mon Sep 17 00:00:00 2001 From: kghs-aver Date: Fri, 27 Dec 2024 23:14:03 +0630 Subject: [PATCH] added resizing upper and lower limits --- .../src/app/simulator/simulator.component.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ArduinoFrontend/src/app/simulator/simulator.component.ts b/ArduinoFrontend/src/app/simulator/simulator.component.ts index f4621c55..1d3c569d 100644 --- a/ArduinoFrontend/src/app/simulator/simulator.component.ts +++ b/ArduinoFrontend/src/app/simulator/simulator.component.ts @@ -208,11 +208,18 @@ export class SimulatorComponent implements OnInit, OnDestroy { onMouseMove(event: MouseEvent) { if (this.isResizing && !this.toggle) { const diff = event.clientX - this.initialMouseX; - this.editorWidth = this.initialWidth + diff; + let newEditorWidth = this.initialWidth + diff; // Minimum width - if (this.editorWidth < 500) { - this.editorWidth = 500; + const minWidth = 150; + if (newEditorWidth < minWidth) { + newEditorWidth= minWidth; } + // Maximum width + const maxWidth = window.innerWidth - 450; + if (newEditorWidth > maxWidth) { + newEditorWidth= maxWidth; + } + this.editorWidth = newEditorWidth; // Update the handle position const handle = document.querySelector('.resize-handle'); if (handle instanceof HTMLElement) {