@@ -17,8 +17,14 @@ export class ScaleHandler implements DraggingHandler {
17
17
const gizmo = e . target as ScaleGizmo ;
18
18
let hside = gizmo . hside ;
19
19
let vside = gizmo . vside ;
20
+ console . log ( hside , object ?. name )
21
+ if ( hside === undefined || vside === undefined ) {
22
+ this . _object = null ;
23
+ return ;
24
+ }
20
25
this . _object = object ;
21
26
27
+
22
28
// inverting axis
23
29
if ( object . scale . x < 0 ) {
24
30
if ( hside == HSide . Left ) hside = HSide . Right ;
@@ -30,23 +36,27 @@ export class ScaleHandler implements DraggingHandler {
30
36
31
37
object . updateTransform ( ) ;
32
38
39
+ let pivotx = 0 ;
40
+ let pivoty = 0 ;
41
+ let x = 0 ;
42
+ let y = 0 ;
43
+
33
44
if ( hside === HSide . Right ) {
34
- object . position . set (
35
- object . x - object . pivot . x * object . scale . x ,
36
- object . y - object . pivot . y ) ;
37
- object . pivot . set ( 0 , 0 ) ;
45
+ pivotx = 0 ;
46
+ x = object . x - object . pivot . x * object . scale . x ;
47
+ y = object . y - object . pivot . y ;
38
48
39
49
40
50
} else if ( hside === HSide . Left ) {
41
51
const originalWidth = object . width / object . scale . x ;
42
- object . position . set (
43
- object . x + object . width - object . pivot . x * object . scale . x ,
44
- object . y - object . pivot . y ) ;
45
-
46
- object . pivot . set ( Math . abs ( originalWidth ) , 0 ) ;
47
- console . log ( originalWidth )
52
+ pivotx = Math . abs ( originalWidth ) ;
53
+
54
+ x = object . x + object . width - object . pivot . x * object . scale . x ;
55
+ y = object . y - object . pivot . y ;
48
56
}
49
57
58
+ object . pivot . set ( pivotx , pivoty ) ;
59
+ object . position . set ( x , y ) ;
50
60
51
61
// this._isGroup = !object.anchor;
52
62
// if (this._isGroup) {
@@ -58,6 +68,7 @@ export class ScaleHandler implements DraggingHandler {
58
68
}
59
69
60
70
public handle ( e : MouseEvent ) : void {
71
+ if ( ! this . _object ) return ;
61
72
if ( ! this . _point ) {
62
73
this . _point = SelectionUtil . mouseEventToGamePoint ( e , { x : 0 , y : 0 } ) ;
63
74
}
0 commit comments