Skip to content

Commit

Permalink
added resizing upper and lower limits
Browse files Browse the repository at this point in the history
  • Loading branch information
kghs-aver committed Dec 27, 2024
1 parent ba98f29 commit c31d16f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ArduinoFrontend/src/app/simulator/simulator.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c31d16f

Please sign in to comment.