Skip to content

Commit

Permalink
selection changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kleber-swf committed Dec 1, 2021
1 parent 965ce85 commit c615d9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/editor-view/selectors/selection-area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,24 @@ export class SelectionArea extends HTMLElement {
// TODO move it to init / enable
public connectedCallback() {
this.appendChild(this.selection);
this.addEventListener('click', this.onClick.bind(this))
this.addEventListener('mouseup', this.onMouseUp.bind(this))
}

private onClick(e: PointerEvent) {
private onMouseUp(e: PointerEvent) {
const game = this.game;
const p = this._touchPoint;
SelectionUtil.pointFromAreaToGame(e.offsetX, e.offsetY, p);
const point = this._touchPoint;
const target = e.target as HTMLElement;

game.add.graphics(p.x, p.y, this.game.world)
SelectionUtil.pointFromAreaToGame(
target.offsetLeft + e.offsetX,
target.offsetTop + e.offsetY,
point);

game.add.graphics(point.x, point.y, this.game.world)
.beginFill(0xFFFF00).drawCircle(0, 0, 20)
.__skip = true;

const obj = this.selector.getObjectAt(p.x, p.y);
const obj = this.selector.getObjectAt(point.x, point.y);
this.selection.object = obj;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/editor-view/selectors/selection/new-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export class NewSelection extends HTMLElement {
style.top = `${_rect.y}px`;
style.width = `${_rect.width}px`;
style.height = `${_rect.height}px`;
console.log(bounds, this._rect);
}
}

Expand Down

0 comments on commit c615d9a

Please sign in to comment.