efront 3.15.1 → 3.15.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/coms/basic/Speed.js +5 -1
- package/coms/basic/cross_.js +5 -0
- package/coms/basic/matrix.js +51 -28
- package/coms/zimoli/list.js +5 -5
- package/coms/zimoli/picture.js +4 -0
- package/coms/zimoli/picture_.js +112 -75
- package/coms/zimoli/picture_test.js +3 -4
- package/coms/zimoli/render.js +7 -3
- package/data/packexe-setup.sfx +0 -0
- package/docs/images/mirror.png +0 -0
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/coms/basic/Speed.js
CHANGED
|
@@ -4,7 +4,7 @@ function inertia(gun) {
|
|
|
4
4
|
if (
|
|
5
5
|
decrease instanceof Function
|
|
6
6
|
) {
|
|
7
|
-
if (!spd.length ||
|
|
7
|
+
if (!spd.length || _decreased > 0 && spd.filter(a => a !== 0).length === 0) return;
|
|
8
8
|
var id = smooth_timer;
|
|
9
9
|
var res = decrease(_decreased++, spd);
|
|
10
10
|
if (smooth_timer !== id) return;
|
|
@@ -70,6 +70,10 @@ class Speed extends Array {
|
|
|
70
70
|
static inertia = inertia;
|
|
71
71
|
reset() {
|
|
72
72
|
this.cache.splice(0, this.cache.length, 0);
|
|
73
|
+
for (var cx = 0, dx = this.length; cx < dx; cx++) {
|
|
74
|
+
if (this[cx] > 0) this[cx] = 1e-13;
|
|
75
|
+
if (this[cx] < 0) this[cx] = -1e-13;
|
|
76
|
+
}
|
|
73
77
|
}
|
|
74
78
|
unset() {
|
|
75
79
|
this.splice(0, this.length), this.cache.splice(0, this.cache.length), this.stamp = 0;
|
package/coms/basic/cross_.js
CHANGED
package/coms/basic/matrix.js
CHANGED
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
// end
|
|
33
33
|
// end
|
|
34
34
|
"use strict";
|
|
35
|
-
|
|
36
35
|
var notMatchLength = new Error("矩阵长度不一致");
|
|
37
|
-
|
|
36
|
+
|
|
37
|
+
function transform(B, dots) {
|
|
38
38
|
var dimention = Math.sqrt(B.length - 1) | 0;
|
|
39
39
|
if (dots.length % dimention !== 0) throw notMatchLength;
|
|
40
40
|
if (dots === B) B = B.slice(0);
|
|
@@ -43,10 +43,11 @@ function transform(dots, B) {
|
|
|
43
43
|
for (var cx = 0, dx = dots.length; cx < dx; cx += dimention) {
|
|
44
44
|
for (var cy = 0, dy = dimention; cy < dy; cy++) {
|
|
45
45
|
var sum = 0;
|
|
46
|
+
var start = dim2 * cy;
|
|
46
47
|
for (var ct = 0, dt = dimention; ct < dt; ct++) {
|
|
47
|
-
sum += ds[cx + ct] * B[
|
|
48
|
+
sum += ds[cx + ct] * B[start + ct];
|
|
48
49
|
}
|
|
49
|
-
sum += B[
|
|
50
|
+
sum += B[start + dimention];
|
|
50
51
|
dots[cx + cy] = sum;
|
|
51
52
|
}
|
|
52
53
|
}
|
|
@@ -56,13 +57,12 @@ function transform(dots, B) {
|
|
|
56
57
|
function translate(A, delta) {
|
|
57
58
|
var [dim2, dim] = size(A);
|
|
58
59
|
var inc = 0;
|
|
59
|
-
for (var cx = dim
|
|
60
|
+
for (var cx = dim, dx = dim * dim2; cx < dx; cx += dim2) {
|
|
60
61
|
A[cx] = (A[cx] || 0) + delta[inc++];
|
|
61
62
|
}
|
|
62
63
|
return A;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
|
|
66
66
|
function 负(a) {
|
|
67
67
|
return -a;
|
|
68
68
|
}
|
|
@@ -76,7 +76,7 @@ function multiply(A, B) {
|
|
|
76
76
|
for (var cy = 0, dy = dim; cy < dy; cy++) {
|
|
77
77
|
var sum = 0;
|
|
78
78
|
for (var ct = 0, dt = dim; ct < dt; ct++) {
|
|
79
|
-
sum +=
|
|
79
|
+
sum += B[cx + ct] * X[ct * dim + cy];
|
|
80
80
|
}
|
|
81
81
|
A[cx + cy] = sum;
|
|
82
82
|
}
|
|
@@ -132,15 +132,17 @@ function olinde(v, vector) {
|
|
|
132
132
|
}
|
|
133
133
|
return v;
|
|
134
134
|
}
|
|
135
|
+
|
|
135
136
|
function matrix2d(theta) {
|
|
136
137
|
var cosa = Math.cos(theta);
|
|
137
138
|
var sina = Math.sin(theta);
|
|
138
139
|
return new Matrix(
|
|
139
|
-
cosa, sina, 0,
|
|
140
|
-
|
|
140
|
+
cosa, -sina, 0,
|
|
141
|
+
sina, cosa, 0,
|
|
141
142
|
0, 0, 1
|
|
142
143
|
);
|
|
143
|
-
}
|
|
144
|
+
}
|
|
145
|
+
|
|
144
146
|
function matrix3d(factor) {
|
|
145
147
|
var theta = norm(factor);
|
|
146
148
|
var vec = times(factor, 1 / theta);
|
|
@@ -150,9 +152,9 @@ function matrix3d(factor) {
|
|
|
150
152
|
var [x_u, y_u, z_u] = factor ? [0, 0, 1] : vec;
|
|
151
153
|
|
|
152
154
|
return new Matrix(
|
|
153
|
-
cosa + x_u * x_u * vera, x_u * y_u * vera
|
|
154
|
-
x_u * y_u * vera
|
|
155
|
-
x_u * z_u * vera
|
|
155
|
+
cosa + x_u * x_u * vera, x_u * y_u * vera + z_u * sina, x_u * z_u * vera - y_u * sina, 0,
|
|
156
|
+
x_u * y_u * vera - z_u * sina, cosa + y_u * y_u * vera, y_u * z_u * vera + x_u * sina, 0,
|
|
157
|
+
x_u * z_u * vera + y_u * sina, y_u * z_u * vera - x_u * sina, cosa + z_u * z_u * vera, 0,
|
|
156
158
|
0, 0, 0, 1
|
|
157
159
|
);
|
|
158
160
|
}
|
|
@@ -173,42 +175,47 @@ var 逆 = function (A) {
|
|
|
173
175
|
A.push.apply(A, E);
|
|
174
176
|
for (var cx = 0, dx = dim; cx < dx; cx++) {
|
|
175
177
|
var start = cx * dim + cx;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
var max_ct, v = 0;
|
|
179
|
+
for (var ct = start, dt = cx * dim + dim; ct < dt; ct++) {
|
|
180
|
+
var v0 = Math.abs(X[ct]);
|
|
181
|
+
if (v0 > v) {
|
|
182
|
+
max_ct = ct;
|
|
183
|
+
v = v0;
|
|
184
|
+
}
|
|
178
185
|
}
|
|
186
|
+
ct = max_ct;
|
|
179
187
|
if (ct !== start) {
|
|
180
188
|
var delta = ct - start;
|
|
181
|
-
var ratio = 1 / X[ct];
|
|
182
|
-
for (var cy = cx
|
|
189
|
+
var ratio = (1 - X[start]) / X[ct];
|
|
190
|
+
for (var cy = cx, dy = X.length; cy < dy; cy += dim) {
|
|
183
191
|
X[cy] += X[cy + delta] * ratio;
|
|
184
192
|
A[cy] += A[cy + delta] * ratio;
|
|
185
193
|
}
|
|
186
194
|
}
|
|
187
195
|
if (X[start] !== 1) {
|
|
188
|
-
var delta = ct - start;
|
|
189
196
|
var ratio = 1 / X[start];
|
|
190
|
-
for (var cy = cx
|
|
197
|
+
for (var cy = cx, dy = X.length; cy < dy; cy += dim) {
|
|
191
198
|
X[cy] *= ratio;
|
|
192
199
|
A[cy] *= ratio;
|
|
193
200
|
}
|
|
194
201
|
}
|
|
195
|
-
for (var ct = start +
|
|
202
|
+
for (var ct = start + 1, dt = start + dim - cx; ct < dt; ct++) {
|
|
196
203
|
if (X[ct] === 0) continue;
|
|
197
204
|
var ratio = -X[ct];
|
|
198
205
|
var delta = start - ct;
|
|
199
|
-
for (var cy = ct -
|
|
206
|
+
for (var cy = cx + ct - start, dy = X.length; cy < dy; cy += dim) {
|
|
200
207
|
X[cy] += X[cy + delta] * ratio;
|
|
201
208
|
A[cy] += A[cy + delta] * ratio;
|
|
202
209
|
}
|
|
203
210
|
}
|
|
204
211
|
}
|
|
205
|
-
for (var cx = dim -
|
|
206
|
-
var start = cx * dim + cx
|
|
207
|
-
for (var ct = start; ct >=
|
|
212
|
+
for (var cx = dim - 1; cx >= 0; cx--) {
|
|
213
|
+
var start = cx * dim + cx;
|
|
214
|
+
for (var ct = start - 1, dt = start - cx; ct >= dt; ct--) {
|
|
208
215
|
if (X[ct] === 0) continue;
|
|
209
216
|
var ratio = -X[ct];
|
|
210
|
-
var delta =
|
|
211
|
-
for (var cy = cx
|
|
217
|
+
var delta = start - ct;
|
|
218
|
+
for (var cy = cx + ct - start, dy = X.length; cy < dy; cy += dim) {
|
|
212
219
|
X[cy] += X[cy + delta] * ratio;
|
|
213
220
|
A[cy] += A[cy + delta] * ratio;
|
|
214
221
|
}
|
|
@@ -245,6 +252,19 @@ class Matrix extends Array {
|
|
|
245
252
|
if (this._invert) return this._invert;
|
|
246
253
|
return this._invert = this.slice().inverse();
|
|
247
254
|
}
|
|
255
|
+
transpose() {
|
|
256
|
+
var [size] = this.size();
|
|
257
|
+
for (var cx = 0, dx = size; cx < dx; cx++) {
|
|
258
|
+
for (var cy = cx + 1, dy = dx; cy < dy; cy++) {
|
|
259
|
+
var i = cx * size + cy;
|
|
260
|
+
var j = cy * size + cx;
|
|
261
|
+
var tmp = this[i];
|
|
262
|
+
this[i] = this[j];
|
|
263
|
+
this[j] = tmp;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return this;
|
|
267
|
+
}
|
|
248
268
|
inverse() {
|
|
249
269
|
this.dirty();
|
|
250
270
|
return 逆(this);
|
|
@@ -276,8 +296,11 @@ class Matrix extends Array {
|
|
|
276
296
|
return multiply(this, a);
|
|
277
297
|
}
|
|
278
298
|
transform(dots) {
|
|
279
|
-
if (dots instanceof Array) return transform(
|
|
280
|
-
if (
|
|
299
|
+
if (dots instanceof Array) return transform(this, dots);
|
|
300
|
+
if (arguments.length > 1) {
|
|
301
|
+
var a = Array.prototype.slice.apply(arguments, 0);
|
|
302
|
+
return transform(this, a);
|
|
303
|
+
}
|
|
281
304
|
return dots;
|
|
282
305
|
}
|
|
283
306
|
}
|
package/coms/zimoli/list.js
CHANGED
|
@@ -143,14 +143,14 @@ function ylist(container, generator, $Y) {
|
|
|
143
143
|
last_index = index;
|
|
144
144
|
continue;
|
|
145
145
|
}
|
|
146
|
-
if (last_index > offset) {
|
|
147
|
-
list.insertBefore(item, last_item);
|
|
148
|
-
} else {
|
|
149
|
-
list.insertBefore(item, getNextSibling(last_item));
|
|
150
|
-
}
|
|
151
146
|
} else {
|
|
152
147
|
delete childrenMap[offset];
|
|
153
148
|
}
|
|
149
|
+
if (last_index > offset) {
|
|
150
|
+
if (item.nextElementSibling !== last_item) list.insertBefore(item, last_item);
|
|
151
|
+
} else {
|
|
152
|
+
if (item.previousElementSibling !== item) list.insertBefore(item, getNextSibling(last_item));
|
|
153
|
+
}
|
|
154
154
|
last_index = offset;
|
|
155
155
|
last_item = item;
|
|
156
156
|
if (offset === index || !indexed_item) indexed_item = item;
|
package/coms/zimoli/picture.js
CHANGED
|
@@ -40,6 +40,10 @@ var create = function (url, key) {
|
|
|
40
40
|
css(imgpic, style);
|
|
41
41
|
if (imgpic) dispatch(imgpic, 'scaled');
|
|
42
42
|
};
|
|
43
|
+
image.close = function () {
|
|
44
|
+
if (!p.touchclose) return false;
|
|
45
|
+
remove(p);
|
|
46
|
+
};
|
|
43
47
|
image.park = function (x, y, scaled, rotate) {
|
|
44
48
|
var style = get_style(x, y, scaled, rotate);
|
|
45
49
|
var a = transition(imgpic, style, true);
|
package/coms/zimoli/picture_.js
CHANGED
|
@@ -11,19 +11,66 @@ var getstation = function (n, s) {
|
|
|
11
11
|
return n;
|
|
12
12
|
};
|
|
13
13
|
var trimCoord = move.trimCoord;
|
|
14
|
-
var isequal = (a, b) => a === b || Math.abs(
|
|
14
|
+
var isequal = (a, b) => a === b || Math.abs(a - b) < .1;
|
|
15
|
+
var aimed = (from, to) => (from + from + from + to) / 4;
|
|
15
16
|
function picture_(image = document.createElement("div")) {
|
|
16
17
|
var image_width, image_height;
|
|
17
|
-
var scaled = 1, x = 0, y = 0, min_scale,
|
|
18
|
+
var scaled = 1, x = 0, y = 0, min_scale, cover_scale, isxrelex, contain_scale, loaded_scale, click_scale, loaded_x, loaded_y;
|
|
18
19
|
var loaded_width, loaded_height;
|
|
19
20
|
var max_scale = 10 * devicePixelRatio;
|
|
20
|
-
var
|
|
21
|
+
var istouching = false;
|
|
22
|
+
var _shape = function (x, y, scaled, rotated) {
|
|
23
|
+
image.rotate = rotated;
|
|
24
|
+
image.scaled = scaled;
|
|
25
|
+
image.x = x;
|
|
26
|
+
image.y = y;
|
|
21
27
|
image.shape(x, y, scaled / devicePixelRatio, rotated);
|
|
22
|
-
|
|
28
|
+
image.locked = (scaled <= contain_scale) && !overflow();
|
|
29
|
+
}
|
|
30
|
+
var shape = function () {
|
|
31
|
+
_shape(x, y, scaled, rotated);
|
|
32
|
+
shaped_rotate = rotated;
|
|
33
|
+
};
|
|
34
|
+
var overflow = function () {
|
|
35
|
+
var deltax = 0, deltay = 0;
|
|
36
|
+
if (scaled <= contain_scale) {
|
|
37
|
+
deltax = x + image_width * scaled / 2 - loaded_width / 2;
|
|
38
|
+
deltay = y + image_height * scaled / 2 - loaded_height / 2;
|
|
39
|
+
}
|
|
40
|
+
else if (scaled <= cover_scale) {
|
|
41
|
+
if (isxrelex) {
|
|
42
|
+
if (x > 0) deltax = x;
|
|
43
|
+
else if (x + image_width * scaled < loaded_width) deltax = loaded_width - x + image_width * scaled;
|
|
44
|
+
deltay = y + image_height * scaled / 2 - loaded_height / 2;
|
|
45
|
+
} else {
|
|
46
|
+
if (y > 0) deltay = y;
|
|
47
|
+
else if (y + image_height * scaled < loaded_height) deltay = y + image_height * scaled - loaded_height;
|
|
48
|
+
deltax = x + image_width * scaled / 2 - loaded_width / 2;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
if (x > 0) deltax = x;
|
|
53
|
+
else if (x + image_width * scaled < loaded_width) deltax = y + image_height * scaled - loaded_height;
|
|
54
|
+
if (y > 0) deltay = y;
|
|
55
|
+
else if (y + image_height * scaled < loaded_height) deltay = y + image_height * scaled - loaded_height;
|
|
56
|
+
}
|
|
57
|
+
if (Math.abs(deltax) > .1 || Math.abs(deltay) > .1) {
|
|
58
|
+
deltax /= loaded_width;
|
|
59
|
+
deltay /= loaded_height;
|
|
60
|
+
|
|
61
|
+
return Math.sqrt(deltax * deltax + deltay * deltay);
|
|
62
|
+
}
|
|
23
63
|
};
|
|
24
64
|
image.reshape = shape;
|
|
25
65
|
var park = function () {
|
|
26
|
-
if (image.
|
|
66
|
+
if (isequal(image.x, x) && isequal(image.y, y) && isequal(image.scaled, scaled) && isequal(image.rotate, rotated)) {
|
|
67
|
+
_shape(x, y, scaled, rotated);
|
|
68
|
+
if (image.park) image.park(x, y, scaled / devicePixelRatio, shaped_rotate);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
_shape(aimed(image.x, x), aimed(image.y, y), aimed(image.scaled, scaled), aimed(image.rotate, rotated));
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
27
74
|
};
|
|
28
75
|
var loadParams = function () {
|
|
29
76
|
if (!image.width) return;
|
|
@@ -31,12 +78,20 @@ function picture_(image = document.createElement("div")) {
|
|
|
31
78
|
image_height = image.height / devicePixelRatio;
|
|
32
79
|
loaded_width = image.clientWidth;
|
|
33
80
|
loaded_height = image.clientHeight;
|
|
34
|
-
|
|
35
|
-
|
|
81
|
+
shaped_rotate = 0;
|
|
82
|
+
var y_scale = loaded_height / image_height;
|
|
83
|
+
var x_scale = loaded_width / image_width;
|
|
84
|
+
isxrelex = x_scale > y_scale;
|
|
85
|
+
cover_scale = isxrelex ? x_scale : y_scale;
|
|
86
|
+
loaded_scale = contain_scale = isxrelex ? y_scale : x_scale;
|
|
36
87
|
if (loaded_scale >= 1) {
|
|
37
88
|
click_scale = 4;
|
|
38
89
|
loaded_scale = 1;
|
|
39
|
-
}
|
|
90
|
+
}
|
|
91
|
+
else if (loaded_scale > .5) {
|
|
92
|
+
click_scale = 2;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
40
95
|
click_scale = 1;
|
|
41
96
|
}
|
|
42
97
|
loaded_x = (loaded_width - image_width * loaded_scale) / 2;
|
|
@@ -46,10 +101,6 @@ function picture_(image = document.createElement("div")) {
|
|
|
46
101
|
x = loaded_x;
|
|
47
102
|
y = loaded_y;
|
|
48
103
|
updatexy();
|
|
49
|
-
set_unlock();
|
|
50
|
-
};
|
|
51
|
-
var set_unlock = function () {
|
|
52
|
-
if (!loaded_scale) return;
|
|
53
104
|
fixpos();
|
|
54
105
|
shape();
|
|
55
106
|
};
|
|
@@ -61,25 +112,14 @@ function picture_(image = document.createElement("div")) {
|
|
|
61
112
|
on("dblclick")(image, function (event) {
|
|
62
113
|
if (event.defaultPrevented) return;
|
|
63
114
|
event.preventDefault();
|
|
64
|
-
var image = this;
|
|
65
|
-
loadParams();
|
|
66
|
-
image.locked = isequal(scaled, loaded_scale) && isequal(loaded_x, x) && isequal(loaded_y, y);
|
|
67
115
|
var layerx = event.offsetX || 0;
|
|
68
116
|
var layery = event.offsetY || 0;
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (layery > loaded_y + height || layery < loaded_y || height < image.offsetHeight >> 2) {
|
|
76
|
-
layery = loaded_y + height / 2;
|
|
77
|
-
}
|
|
78
|
-
scale(layerx, layery, click_scale / loaded_scale);
|
|
79
|
-
} else {
|
|
80
|
-
click_scale = scaled;
|
|
81
|
-
set_unlock();
|
|
82
|
-
}
|
|
117
|
+
if (isequal(scaled, loaded_scale)) {
|
|
118
|
+
scale(layerx, layery, click_scale / scaled);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
scale(layerx, layery, loaded_scale / scaled);
|
|
122
|
+
}
|
|
83
123
|
});
|
|
84
124
|
image.getScale = function () {
|
|
85
125
|
if (!this.locked && !loaded_scale) {
|
|
@@ -99,7 +139,6 @@ function picture_(image = document.createElement("div")) {
|
|
|
99
139
|
y += y1 - y0;
|
|
100
140
|
};
|
|
101
141
|
var scale = function (layerx, layery, ratio) {
|
|
102
|
-
if (!image.locked) return;
|
|
103
142
|
scaled *= ratio;
|
|
104
143
|
x = (x - layerx) * ratio + layerx;
|
|
105
144
|
y = (y - layery) * ratio + layery;
|
|
@@ -112,30 +151,23 @@ function picture_(image = document.createElement("div")) {
|
|
|
112
151
|
if (scaled >= max_scale * 1.1 && scale > 1) return;
|
|
113
152
|
if (scaled <= min_scale && scale < 1) return;
|
|
114
153
|
scaled *= scale;
|
|
115
|
-
var
|
|
116
|
-
var
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
x = (x - centerx) * scale + centerm;
|
|
120
|
-
y = (y - centery) * scale + centern;
|
|
154
|
+
var ox = image.clientWidth / 2;
|
|
155
|
+
var oy = image.clientHeight / 2;
|
|
156
|
+
x = (x - x1) * scale + ox;
|
|
157
|
+
y = (y - y1) * scale + oy;
|
|
121
158
|
var theta = Math.atan2(n2 - n1, m2 - m1) - Math.atan2(y2 - y1, x2 - x1);
|
|
122
159
|
var r = rotated;
|
|
123
160
|
r += (theta * 180 / Math.PI);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
// var hh = image.clientHeight / 2;
|
|
129
|
-
// console.log(x, y);
|
|
130
|
-
// x -= hw;
|
|
131
|
-
// y -= hh;
|
|
132
|
-
// var x0 = x * cosa - y * sina;
|
|
133
|
-
// var y0 = x * sina + y * cosa;
|
|
134
|
-
// x = x0 + hw;
|
|
135
|
-
// y = y0 + hh;
|
|
161
|
+
rotated = r;
|
|
162
|
+
updatexy();
|
|
163
|
+
x = x - ox + m1;
|
|
164
|
+
y = y - oy + n1;
|
|
136
165
|
shape();
|
|
137
166
|
};
|
|
138
167
|
var recover = function (change) {
|
|
168
|
+
if (image.close && scaled < cover_scale && overflow() > .3) {
|
|
169
|
+
if (image.close() !== false) return;
|
|
170
|
+
}
|
|
139
171
|
var aimed_scale = getstation(scaled);
|
|
140
172
|
if (aimed_scale !== scaled) {
|
|
141
173
|
change = true;
|
|
@@ -158,24 +190,21 @@ function picture_(image = document.createElement("div")) {
|
|
|
158
190
|
var saved_x = x, saved_y = y;
|
|
159
191
|
fixpos();
|
|
160
192
|
if (change || saved_x !== x || saved_y !== y) {
|
|
161
|
-
park
|
|
193
|
+
move.smooth(park);
|
|
162
194
|
return;
|
|
163
195
|
}
|
|
164
|
-
if (image.clientHeight && image.clientWidth) return true;
|
|
165
196
|
};
|
|
166
197
|
var move = inertia(function (deltax, deltay) {
|
|
167
198
|
var saved_x = x, saved_y = y;
|
|
168
199
|
x += deltax, y += deltay;
|
|
169
|
-
fixpos();
|
|
200
|
+
if (scaled > contain_scale) fixpos();
|
|
170
201
|
shape();
|
|
171
|
-
if (saved_x === x && saved_y === y) return false;
|
|
202
|
+
if (saved_x === x && saved_y === y || overflow() > 1) return false;
|
|
172
203
|
});
|
|
173
204
|
var saved_event;
|
|
174
205
|
onmousewheel(image, function (event) {
|
|
175
206
|
var { offsetX: layerX, offsetY: layerY, deltaY } = event;
|
|
176
|
-
if (this.locked) event.preventDefault();
|
|
177
207
|
if (!deltaY) return;
|
|
178
|
-
if (!this.locked) loadParams();
|
|
179
208
|
this.locked = true;
|
|
180
209
|
var ratio = Math.pow(0.99, 20 * Math.atan(deltaY / 20));
|
|
181
210
|
var __scaled = scaled;
|
|
@@ -193,18 +222,15 @@ function picture_(image = document.createElement("div")) {
|
|
|
193
222
|
start(event) {
|
|
194
223
|
event.preventDefault();
|
|
195
224
|
saved_event = event;
|
|
196
|
-
|
|
197
|
-
if (!this.locked) {
|
|
198
|
-
loadParams();
|
|
199
|
-
}
|
|
225
|
+
istouching = !this.locked;
|
|
200
226
|
move.reset();
|
|
201
227
|
},
|
|
202
228
|
move(event) {
|
|
203
229
|
if (event.moveLocked) return;
|
|
204
|
-
|
|
205
|
-
event.preventDefault();
|
|
230
|
+
if (!onclick.preventClick) return;
|
|
206
231
|
if (event.touches && saved_event.touches) {
|
|
207
232
|
if (event.touches.length !== saved_event.touches.length) {
|
|
233
|
+
event.moveLocked = true;
|
|
208
234
|
saved_event = event;
|
|
209
235
|
return;
|
|
210
236
|
}
|
|
@@ -213,7 +239,7 @@ function picture_(image = document.createElement("div")) {
|
|
|
213
239
|
case 1:
|
|
214
240
|
break;
|
|
215
241
|
case 2:
|
|
216
|
-
|
|
242
|
+
default:
|
|
217
243
|
event.moveLocked = true;
|
|
218
244
|
var [xy1, xy2] = saved_event.touches;
|
|
219
245
|
var [mn1, mn2] = event.touches;
|
|
@@ -226,6 +252,7 @@ function picture_(image = document.createElement("div")) {
|
|
|
226
252
|
);
|
|
227
253
|
saved_event = event;
|
|
228
254
|
return;
|
|
255
|
+
|
|
229
256
|
}
|
|
230
257
|
}
|
|
231
258
|
if (event.which === 3) {
|
|
@@ -233,39 +260,49 @@ function picture_(image = document.createElement("div")) {
|
|
|
233
260
|
rotatexy(saved_event.clientX, saved_event.clientY, event.clientX, event.clientY);
|
|
234
261
|
}
|
|
235
262
|
else {
|
|
236
|
-
if (!this.locked) return;
|
|
237
263
|
var deltax = event.clientX - saved_event.clientX,
|
|
238
264
|
deltay = event.clientY - saved_event.clientY;
|
|
239
|
-
|
|
265
|
+
|
|
266
|
+
if (!istouching && istouching !== null) {
|
|
267
|
+
istouching = Math.abs(deltay) > Math.abs(deltax) ? true : null;
|
|
268
|
+
}
|
|
269
|
+
if (istouching) {
|
|
270
|
+
event.moveLocked = true;
|
|
271
|
+
move(deltax, deltay);
|
|
272
|
+
}
|
|
240
273
|
}
|
|
241
274
|
saved_event = event;
|
|
242
275
|
},
|
|
243
276
|
end(event) {
|
|
277
|
+
if (event.touches && event.touches.length > 0) return;
|
|
278
|
+
istouching = false;
|
|
244
279
|
if (saved_event) {
|
|
245
280
|
if (event.timeStamp - saved_event.timeStamp > 120) {
|
|
246
281
|
move.reset();
|
|
247
282
|
}
|
|
248
283
|
}
|
|
249
284
|
saved_event = null;
|
|
250
|
-
|
|
251
|
-
if (this.locked && onclick.preventClick) move.smooth();
|
|
285
|
+
if (onclick.preventClick) move.smooth(recover);
|
|
252
286
|
}
|
|
253
287
|
});
|
|
254
|
-
var
|
|
288
|
+
var shaped_rotate = 0, rotated = 0;
|
|
255
289
|
var rotatexy = function (x1, y1, x2, y2) {
|
|
256
290
|
var { left, top } = getScreenPosition(image);
|
|
257
291
|
var centerx = left + image.clientLeft + image.clientWidth / 2, centery = top + image.clientTop + image.clientHeight / 2;
|
|
258
|
-
var deltax = x2 - x1, deltay = y2 - y1;
|
|
259
|
-
var rx = x1 - centerx, ry = y1 - centery;
|
|
260
|
-
var sign = -ry * deltax + rx * deltay;
|
|
261
|
-
var delta =
|
|
262
|
-
if (delta > 10) delta = 10;
|
|
263
|
-
|
|
292
|
+
// var deltax = x2 - x1, deltay = y2 - y1;
|
|
293
|
+
// var rx = x1 - centerx, ry = y1 - centery;
|
|
294
|
+
// var sign = -ry * deltax + rx * deltay;
|
|
295
|
+
// var delta = Math.sqrt(deltax * deltax + deltay * deltay) / Math.sqrt(rx * rx + ry * ry);
|
|
296
|
+
// if (delta > 10) delta = 10;
|
|
297
|
+
// delta *= sign > 0 ? 1 : -1;
|
|
298
|
+
if (isequal(x1, centerx) && isequal(y1, centery) || isequal(x2, centerx) && isequal(y2, centery)) return;
|
|
299
|
+
var delta = Math.atan2(y2 - centery, x2 - centerx) - Math.atan2(y1 - centery, x1 - centerx);
|
|
300
|
+
rotated += delta * 180 / Math.PI, updatexy(), shape();
|
|
264
301
|
}
|
|
265
302
|
var updatexy = function () {
|
|
266
|
-
var deg = rotated -
|
|
303
|
+
var deg = rotated - shaped_rotate;
|
|
267
304
|
if (isFinite(deg)) {
|
|
268
|
-
|
|
305
|
+
shaped_rotate = rotated;
|
|
269
306
|
[x, y] = getrotatedltwh(deg, scaled);
|
|
270
307
|
}
|
|
271
308
|
};
|
|
@@ -278,7 +315,7 @@ function picture_(image = document.createElement("div")) {
|
|
|
278
315
|
var [c1, c2] = rotate([m, n], -a, c);
|
|
279
316
|
c1 -= w / 2;
|
|
280
317
|
c2 -= h / 2;
|
|
281
|
-
var a =
|
|
318
|
+
var a = shaped_rotate;
|
|
282
319
|
var l = c[0] - w / 2;
|
|
283
320
|
var r = l + w;
|
|
284
321
|
var t = c[1] - h / 2;
|
package/coms/zimoli/render.js
CHANGED
|
@@ -585,7 +585,7 @@ var emiters = {
|
|
|
585
585
|
emiters.v = emiters.ng = emiters.on;
|
|
586
586
|
|
|
587
587
|
function getFromScopes(key, scope, parentScopes) {
|
|
588
|
-
if (key in scope) {
|
|
588
|
+
if (scope) if (key in scope) {
|
|
589
589
|
return scope[key];
|
|
590
590
|
}
|
|
591
591
|
if (parentScopes) for (var cx = parentScopes.length - 1; cx >= 0; cx--) {
|
|
@@ -725,7 +725,7 @@ function renderStructure(element, scope, parentScopes = []) {
|
|
|
725
725
|
var attrs = [].concat.apply([], element.attributes);
|
|
726
726
|
var withContext = parentScopes ? parentScopes.map((_, cx) => `with(this.$parentScopes[${cx}])`).join("") : '';
|
|
727
727
|
var types = {};
|
|
728
|
-
var emiter_reg = /^(?:(v|ng|on|once)
|
|
728
|
+
var emiter_reg = /^(?:(v|ng|on|once)?\-|v\-on\:|@|once|on)/i;
|
|
729
729
|
var ons = [];
|
|
730
730
|
var copys = [];
|
|
731
731
|
var binds = {};
|
|
@@ -768,21 +768,25 @@ function renderStructure(element, scope, parentScopes = []) {
|
|
|
768
768
|
continue;
|
|
769
769
|
}
|
|
770
770
|
if (element.$struct) continue;
|
|
771
|
-
|
|
771
|
+
// ng-html,ng-src,ng-text,ng-model,ng-style,ng-class,...
|
|
772
|
+
var key = name.replace(/^(ng|v|[^\_\:\.]*?)\-|^[\:\_\.]|^v\-bind\:/i, "").toLowerCase();
|
|
772
773
|
if (directives.hasOwnProperty(key) || /^([\_\:\.]|v\-bind\:)/.test(name)) {
|
|
773
774
|
binds[key] = value;
|
|
774
775
|
element.removeAttribute(name);
|
|
775
776
|
}
|
|
777
|
+
// ng-click on-click v-click @click @mousedown ...
|
|
776
778
|
else if (emiter_reg.test(name)) {
|
|
777
779
|
var match = emiter_reg.exec(name);
|
|
778
780
|
var ngon = (match[1] || match[0]).toLowerCase() === 'once' ? 'once' : 'on';
|
|
779
781
|
element.removeAttribute(name);
|
|
780
782
|
ons.push([emiters[ngon], name.replace(emiter_reg, ''), value]);
|
|
781
783
|
}
|
|
784
|
+
// placeholder_ href_ checked_ ...
|
|
782
785
|
else if (/[_@\:\.]$/.test(name)) {
|
|
783
786
|
attr1[name.replace(/[_@\:\.]$/, "")] = value;
|
|
784
787
|
element.removeAttribute(name);
|
|
785
788
|
}
|
|
789
|
+
// title alt name type placeholder href checked ...
|
|
786
790
|
else {
|
|
787
791
|
if (!/\-/.test(name) || value === '') {
|
|
788
792
|
copys.push(attr);
|
package/data/packexe-setup.sfx
CHANGED
|
Binary file
|
|
Binary file
|