File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
packages/core/src/customs Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,27 @@ import { fabric } from 'fabric';
2
2
3
3
export class Polyline extends fabric . Polyline {
4
4
public onSelect ( options : { e ?: Event | undefined } ) : boolean {
5
+ const points = this . points ?? [ ] ;
6
+ this . controls = points . reduce < Record < string , fabric . Control > > (
7
+ ( controls , point , index ) => {
8
+ controls [ `p${ index } ` ] = new fabric . Control ( {
9
+ actionName : 'modifyPolyline' ,
10
+ positionHandler ( dim , finalMatrix , fabricObject : Polyline ) {
11
+ const x = point . x - fabricObject . pathOffset . x ;
12
+ const y = point . y - fabricObject . pathOffset . y ;
13
+ return fabric . util . transformPoint (
14
+ new fabric . Point ( x , y ) ,
15
+ fabric . util . multiplyTransformMatrices (
16
+ fabricObject . canvas ?. viewportTransform ?? [ ] ,
17
+ fabricObject . calcTransformMatrix ( )
18
+ )
19
+ ) ;
20
+ } ,
21
+ } ) ;
22
+ return controls ;
23
+ } ,
24
+ { ...this . controls }
25
+ ) ;
5
26
return super . onSelect ( options ) ;
6
27
}
7
28
You can’t perform that action at this time.
0 commit comments