default shape size
This commit is contained in:
parent
14c2cac1db
commit
abf1d73aa6
|
|
@ -55,7 +55,7 @@ export class FolkShapeTool extends FolkInteractionHandler {
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case 'pointerdown':
|
case 'pointerdown':
|
||||||
if (!target || target instanceof FolkShape) return;
|
if (!target || target instanceof FolkShape || target instanceof FolkInteractionHandler) return;
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
|
|
||||||
const rect = target.getBoundingClientRect();
|
const rect = target.getBoundingClientRect();
|
||||||
|
|
@ -106,13 +106,18 @@ export class FolkShapeTool extends FolkInteractionHandler {
|
||||||
if (!this.currentShape) return;
|
if (!this.currentShape) return;
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
|
|
||||||
// Remove shape if it's too small
|
// If the shape is too small (meaning almost no drag occurred)
|
||||||
if (this.currentShape.width < 10 || this.currentShape.height < 10) {
|
// create a default sized shape instead
|
||||||
this.currentShape.remove();
|
if (this.currentShape.width <= 1 || this.currentShape.height <= 1) {
|
||||||
} else {
|
const defaultSize = 100;
|
||||||
this.currentShape.focus();
|
this.currentShape.width = defaultSize;
|
||||||
|
this.currentShape.height = defaultSize;
|
||||||
|
// Center the shape on the click point
|
||||||
|
this.currentShape.x = this.startPoint!.x - defaultSize / 2;
|
||||||
|
this.currentShape.y = this.startPoint!.y - defaultSize / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.currentShape.focus();
|
||||||
target.releasePointerCapture(event.pointerId);
|
target.releasePointerCapture(event.pointerId);
|
||||||
this.currentShape = null;
|
this.currentShape = null;
|
||||||
this.startPoint = null;
|
this.startPoint = null;
|
||||||
|
|
@ -182,7 +187,7 @@ export class FolkToolset extends HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If clicking same tool, just deactivate
|
// If clicking same tool, just deactivate
|
||||||
if (this.currentHandler === tool.handleEvent.bind(tool)) {
|
if (this.activeTool === tool) {
|
||||||
this.currentHandler = null;
|
this.currentHandler = null;
|
||||||
this.activeTool = null;
|
this.activeTool = null;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue