@@ -20,6 +20,7 @@ Vue.mixin({
20
20
setCanvasStyle ( canvasRef , parentRef , space = 0 ) {
21
21
this . $nextTick ( ( ) => {
22
22
let canvas = this . $refs [ canvasRef ] ;
23
+ const parent = this . $refs [ parentRef ] ;
23
24
console . log ( "====setCanvasStyle" , JSON . stringify ( this . canvasStyle ) )
24
25
if ( this . canvasStyle . intWidth ) {
25
26
canvas . style . setProperty ( "--w" , this . canvasStyle . intWidth + "px" ) ;
@@ -28,6 +29,7 @@ Vue.mixin({
28
29
canvas . style . setProperty ( "--h" , this . canvasStyle . intHeight + "px" ) ;
29
30
}
30
31
if ( this . canvasStyle . backgroundColor ) {
32
+ parent . style . setProperty ( "--color" , this . canvasStyle . backgroundColor ) ;
31
33
canvas . style . setProperty ( "--color" , this . canvasStyle . backgroundColor ) ;
32
34
}
33
35
this . defaultScale = this . getScale ( parentRef , space ) ;
@@ -40,28 +42,18 @@ Vue.mixin({
40
42
if ( cpt . style . height ) cpt . point . h = cpt . style . height ;
41
43
return cpt . style ;
42
44
} ,
43
- setZoom ( step ) {
44
- if ( this . defaultScale >= 1.5 && step > 0 ) return ;
45
- if ( this . defaultScale <= 0.5 && step < 0 ) return ;
46
- this . defaultScale += step ;
47
- console . log ( "====setZoom" , step )
48
- let droppable = document . getElementById ( "droppable" )
49
- droppable . style . transform = "scale(" + this . defaultScale + ")" ;
50
- } ,
51
45
getScale ( refName , space ) {
52
46
const parent = this . $refs [ refName ] ;
53
47
// 画布父容器宽度
54
48
const parentW = parent . offsetWidth ;
55
49
// 画布父容器高度
56
50
const parentH = parent . offsetHeight ;
57
51
console . log ( "====parent" , parent . offsetWidth , parent . offsetHeight )
58
- let scaleX = ( parentW + space ) / this . canvasStyle . intWidth ;
59
- let scaleY = ( parentH + space ) / this . canvasStyle . intHeight ;
60
- if ( space > 0 ) {
61
- return Math . max ( scaleX , scaleY ) ;
62
- } else {
63
- return Math . min ( scaleX , scaleY ) ;
64
- }
52
+ console . log ( "====window" , window . innerWidth , window . innerHeight )
53
+ let scaleX = ( parentW - space ) / this . canvasStyle . intWidth ;
54
+ let scaleY = ( parentH - space ) / this . canvasStyle . intHeight ;
55
+
56
+ return Math . min ( scaleX , scaleY ) ;
65
57
} ,
66
58
handleUnselect ( cptId ) {
67
59
const unselect = ( cptId ) => {
0 commit comments