-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLiveScaleTransform2.index.js
123 lines (115 loc) · 2.79 KB
/
LiveScaleTransform2.index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import { defaultTo } from "fxjs/es";
import { $$getSVG } from "../getSetSVG/getSetSVG.index.js";
import { $$initScaleTransform } from "../initScaleTransform/initScaleTransform.index.js";
import { $$LiveTransform } from "../LiveTransform/LiveTransform.index.js";
import { $$mergeScaleTransform2 } from "../mergeScaleTransform2/mergeScaleTransform2.index.js";
import { $$updateScaleTransform } from "../updateScaleTransform/updateScaleTransform.index.js";
export class $$LiveScaleTransform2 extends $$LiveTransform {
constructor(
{
index = 0,
cx = 0,
cy = 0,
sx = 1,
sy = 1,
is_need_correction = true,
x_name,
y_name,
width_name,
height_name,
direction,
} = {},
$el,
$svg = $$getSVG()
) {
super();
this.is_done = false;
this.transform = $$initScaleTransform({ sx, sy, cx, cy, index })($el, $svg);
this.index = index;
this.is_need_correction = is_need_correction;
this.x_name = x_name;
this.y_name = y_name;
this.width_name = width_name;
this.height_name = height_name;
this.direction = direction;
this.$el = $el;
}
static $$create({
index = 0,
cx = 0,
cy = 0,
sx = 1,
sy = 1,
is_need_correction = true,
x_name,
y_name,
width_name,
height_name,
direction,
} = {}) {
return ($el, $svg = $$getSVG()) =>
new $$LiveScaleTransform2(
{
index,
cx,
cy,
sx,
sy,
is_need_correction,
x_name,
y_name,
width_name,
height_name,
direction,
},
$el,
$svg
);
}
$$getIsDone() {
return this.is_done;
}
$$done() {
this.is_done = true;
}
$$update({ sx, sy } = {}) {
$$updateScaleTransform({ sx, sy })(this.transform);
}
$$merge({
is_need_correction: is_need_correction1,
x_name: x_name1,
y_name: y_name1,
width_name: width_name1,
height_name: height_name1,
direction: direction1,
} = {}) {
const {
$el,
index,
is_need_correction: is_need_correction2,
x_name: x_name2,
y_name: y_name2,
width_name: width_name2,
height_name: height_name2,
direction: direction2,
} = this;
const is_need_correction = defaultTo(
is_need_correction2,
is_need_correction1
);
const x_name = defaultTo(x_name2, x_name1);
const y_name = defaultTo(y_name2, y_name1);
const width_name = defaultTo(width_name2, width_name1);
const height_name = defaultTo(height_name2, height_name1);
const direction = defaultTo(direction2, direction1);
$$mergeScaleTransform2({
index: index + 1,
is_need_correction,
x_name,
y_name,
width_name,
height_name,
direction,
})($el);
}
}