Skip to content

Commit

Permalink
fix: resize group without focus
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfran committed Feb 20, 2025
1 parent 438cf93 commit d1ddba3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ import { boardPageFeature } from '../../reducers/boardPage.reducer';
}
}
</div>
<tapiz-resize-single [node]="node()" />
<tapiz-resize-single
[node]="node()"
(initResize)="initResize()" />
`,
styleUrls: ['./group.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down Expand Up @@ -274,4 +276,11 @@ export class GroupComponent {
public get nativeElement(): HTMLElement {
return this.#el.nativeElement as HTMLElement;
}

initResize() {
this.#nodesStore.setFocusNode({
id: this.node().id,
ctrlKey: false,
});
}
}
22 changes: 14 additions & 8 deletions libs/ui/src/lib/resize/resize-handler-single.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ElementRef,
afterNextRender,
inject,
output,
} from '@angular/core';

import { MoveService } from '@tapiz/cdk/services/move.service';
Expand Down Expand Up @@ -34,29 +35,30 @@ export class ResizeHandlerSingleComponent implements Resizable {
private resizeService = inject(ResizeService);
private el: ElementRef<HTMLElement> = inject(ElementRef);

public node = input.required<TuNode<Resizable>>();
node = input.required<TuNode<Resizable>>();
initResize = output();

public get nodeType() {
get nodeType() {
return this.node().type;
}

public get width() {
get width() {
return this.node().content.width;
}

public get height() {
get height() {
return this.node().content.height;
}

public get position() {
get position() {
return this.node().content.position;
}

public get rotation() {
get rotation() {
return this.node().content.rotation;
}

public get id() {
get id() {
return this.node().id;
}

Expand All @@ -66,11 +68,15 @@ export class ResizeHandlerSingleComponent implements Resizable {
});
}

public listen(handler: HTMLElement, position: ResizePosition) {
listen(handler: HTMLElement, position: ResizePosition) {
this.moveService
.mouseDownAndMove(handler)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((mouseEvent) => {
if (mouseEvent.type === 'start') {
this.initResize.emit();
}

this.resizeService.resizeEvent.next({
...mouseEvent,
position,
Expand Down

0 comments on commit d1ddba3

Please sign in to comment.