File tree Expand file tree Collapse file tree 4 files changed +25
-14
lines changed Expand file tree Collapse file tree 4 files changed +25
-14
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,9 @@ class EllipseTool implements Tool {
50
50
public onMouseUp ( { app } : AppMouseEvent ) : void {
51
51
app . setTool ( selectTool ) ;
52
52
this . startPointer . setXY ( 0 , 0 ) ;
53
- this . ellipse && app . canvas . setActiveObject ( this . ellipse ) ;
53
+ if ( this . ellipse ) {
54
+ app . canvas . setActiveObject ( this . ellipse ) ;
55
+ }
54
56
this . ellipse = null ;
55
57
app . render ( true ) ;
56
58
}
Original file line number Diff line number Diff line change @@ -12,14 +12,21 @@ class PolylineTool implements Tool {
12
12
private polyline : Polyline | null = null ;
13
13
14
14
public onMouseDown ( { app } : AppMouseEvent ) : void {
15
+ console . log ( 'mouseDown' ) ;
16
+
15
17
app . canvas . selection = false ;
16
18
this . points . push ( app . pointer ) ;
17
- this . polyline = new Polyline ( this . points , {
18
- fill : 'transparent' ,
19
- stroke : 'black' ,
20
- strokeWidth : 2 ,
21
- } ) ;
22
- app . canvas . add ( this . polyline ) ;
19
+ if ( ! this . polyline ) {
20
+ this . polyline = new Polyline ( this . points , {
21
+ fill : 'transparent' ,
22
+ stroke : 'black' ,
23
+ strokeWidth : 2 ,
24
+ } ) ;
25
+ app . canvas . add ( this . polyline ) ;
26
+ } else {
27
+ this . polyline . points = this . points ;
28
+ app . render ( ) ;
29
+ }
23
30
}
24
31
25
32
public onMouseMove ( { app } : AppMouseEvent ) : void {
@@ -34,13 +41,11 @@ class PolylineTool implements Tool {
34
41
app . render ( ) ; // Call render after updating the polyline
35
42
}
36
43
37
- public onMouseUp ( { app, event } : AppMouseEvent ) : void {
44
+ public onMouseDoubleClick ( { app } : AppMouseEvent ) {
38
45
app . setTool ( selectTool ) ;
46
+
39
47
if ( this . polyline ) {
40
- // Use setTimeout to delay the selection after the fabric.js selection process is done
41
- setTimeout ( ( ) => {
42
- app . canvas . setActiveObject ( this . polyline ! , event . e ) ;
43
- } , 10 ) ;
48
+ app . canvas . setActiveObject ( this . polyline ) ;
44
49
}
45
50
46
51
this . points = [ ] ;
Original file line number Diff line number Diff line change @@ -39,7 +39,9 @@ class RectTool implements Tool {
39
39
public onMouseUp ( { app } : AppMouseEvent ) : void {
40
40
app . setTool ( selectTool ) ;
41
41
this . startPointer . setXY ( 0 , 0 ) ;
42
- this . rectangle && app . canvas . setActiveObject ( this . rectangle ) ;
42
+ if ( this . rectangle ) {
43
+ app . canvas . setActiveObject ( this . rectangle ) ;
44
+ }
43
45
this . rectangle = null ;
44
46
app . render ( true ) ;
45
47
}
Original file line number Diff line number Diff line change @@ -39,7 +39,9 @@ class TriangleTool implements Tool {
39
39
public onMouseUp ( { app } : AppMouseEvent ) : void {
40
40
app . setTool ( selectTool ) ;
41
41
this . startPointer . setXY ( 0 , 0 ) ;
42
- this . triangle && app . canvas . setActiveObject ( this . triangle ) ;
42
+ if ( this . triangle ) {
43
+ app . canvas . setActiveObject ( this . triangle ) ;
44
+ }
43
45
this . triangle = null ;
44
46
app . render ( true ) ;
45
47
}
You can’t perform that action at this time.
0 commit comments