(event: MouseEvent)
| 183 | } |
| 184 | |
| 185 | private handleResize(event: MouseEvent) { |
| 186 | const windowWidth = window.innerWidth; |
| 187 | const windowHeight = window.innerHeight; |
| 188 | |
| 189 | const deltaX = event.clientX - this.resizeStartX; |
| 190 | const deltaY = event.clientY - this.resizeStartY; |
| 191 | |
| 192 | const deltaXPercent = (deltaX / windowWidth) * 100; |
| 193 | const deltaYPercent = (deltaY / windowHeight) * 100; |
| 194 | |
| 195 | let newWidth = this.resizeStartWidth; |
| 196 | let newHeight = this.resizeStartHeight; |
| 197 | let newX = this.resizeStartWindowX; |
| 198 | let newY = this.resizeStartWindowY; |
| 199 | |
| 200 | const minWidth = 20; // Minimum 20% width |
| 201 | const minHeight = 20; // Minimum 20% height |
| 202 | |
| 203 | // Handle different resize directions |
| 204 | if (this.resizeDirection.includes('right')) { |
| 205 | newWidth = Math.max(minWidth, Math.min(this.resizeStartWidth + deltaXPercent, 100 - this.resizeStartWindowX)); |
| 206 | } |
| 207 | if (this.resizeDirection.includes('left')) { |
| 208 | const widthChange = -deltaXPercent; |
| 209 | newWidth = Math.max(minWidth, Math.min(this.resizeStartWidth + widthChange, this.resizeStartWidth + this.resizeStartWindowX)); |
| 210 | if (newWidth !== this.resizeStartWidth) { |
| 211 | newX = this.resizeStartWindowX + (this.resizeStartWidth - newWidth); |
| 212 | } |
| 213 | } |
| 214 | if (this.resizeDirection.includes('bottom')) { |
| 215 | newHeight = Math.max(minHeight, Math.min(this.resizeStartHeight + deltaYPercent, 100 - this.resizeStartWindowY)); |
| 216 | } |
| 217 | if (this.resizeDirection.includes('top')) { |
| 218 | const heightChange = -deltaYPercent; |
| 219 | newHeight = Math.max(minHeight, Math.min(this.resizeStartHeight + heightChange, this.resizeStartHeight + this.resizeStartWindowY)); |
| 220 | if (newHeight !== this.resizeStartHeight) { |
| 221 | newY = this.resizeStartWindowY + (this.resizeStartHeight - newHeight); |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | // Ensure window stays within bounds |
| 226 | if (newX + newWidth > 100) { |
| 227 | newWidth = 100 - newX; |
| 228 | } |
| 229 | if (newY + newHeight > 100) { |
| 230 | newHeight = 100 - newY; |
| 231 | } |
| 232 | if (newX < 0) { |
| 233 | newWidth += newX; |
| 234 | newX = 0; |
| 235 | } |
| 236 | if (newY < 0) { |
| 237 | newHeight += newY; |
| 238 | newY = 0; |
| 239 | } |
| 240 | |
| 241 | this.windowManager.updateWindowPosition(this.windowState.id, newX, newY); |
| 242 | this.windowManager.updateWindowSize(this.windowState.id, newWidth, newHeight); |
no test coverage detected