efront 3.14.0 → 3.14.9
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/Array2.js +9 -0
- package/coms/basic/Speed.js +120 -0
- package/coms/basic/assert.js +11 -2
- package/coms/basic/matrix.js +283 -0
- package/coms/basic/parseYML.js +5 -3
- package/coms/compile/common.js +6 -2
- package/coms/kugou/buildScroll.less +4 -0
- package/coms/zimoli/autodragchildren.js +2 -2
- package/coms/zimoli/confirm.js +0 -3
- package/coms/zimoli/data.js +3 -1
- package/coms/zimoli/drag.js +23 -6
- package/coms/zimoli/inertia.js +1 -70
- package/coms/zimoli/isMounted.js +4 -1
- package/coms/zimoli/lattice.js +1 -0
- package/coms/zimoli/list.js +43 -25
- package/coms/zimoli/matrix_test.js +10 -0
- package/coms/zimoli/menu.less +3 -1
- package/coms/zimoli/oncemount.js +7 -0
- package/coms/zimoli/onmounted.js +0 -1
- package/coms/zimoli/picture_.js +64 -58
- package/coms/zimoli/popup.js +1 -1
- package/coms/zimoli/render.js +13 -8
- package/coms/zimoli/search.js +4 -1
- package/coms/zimoli/slider.js +4 -2
- package/coms/zimoli/speed.js +10 -14
- package/coms/zimoli/speed_test.js +34 -0
- package/coms/zimoli/table.html +3 -1
- package/coms/zimoli/table.js +13 -10
- package/coms/zimoli/table.less +29 -12
- package/coms/zimoli/tree.less +0 -2
- package/coms/zimoli/vbox.js +34 -68
- package/coms/zimoli/vscroll.js +3 -2
- package/coms/zimoli/zIndex.js +5 -3
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/coms/zimoli/matrix.js +0 -146
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
|
|
2
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
3
|
+
for (var p in proto) if (!hasOwnProperty.call(obj)) obj[p] = proto[p];
|
|
4
|
+
return obj;
|
|
5
|
+
}
|
|
6
|
+
function Array2() {
|
|
7
|
+
return setPrototypeOf(Array.apply(this, arguments), this.constructor.prototype);
|
|
8
|
+
}
|
|
9
|
+
Array2.prototype = Array.prototype;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
function inertia(gun) {
|
|
2
|
+
var _decreased = 0, spd = new Speed;
|
|
3
|
+
var _decrease = function () {
|
|
4
|
+
if (
|
|
5
|
+
decrease instanceof Function
|
|
6
|
+
) {
|
|
7
|
+
if (!spd.length || !spd[0]) return;
|
|
8
|
+
var id = smooth_timer;
|
|
9
|
+
var res = decrease(_decreased++, spd);
|
|
10
|
+
if (smooth_timer !== id) return;
|
|
11
|
+
if (res === false || isEmpty(res)) {
|
|
12
|
+
spd.unset();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
smooth_timer = requestAnimationFrame(_decrease);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var _cancel = function () {
|
|
19
|
+
cancelAnimationFrame(smooth_timer);
|
|
20
|
+
_decreased = 0;
|
|
21
|
+
decrease = null;
|
|
22
|
+
}
|
|
23
|
+
var smooth = function () {
|
|
24
|
+
var args = spd.read();
|
|
25
|
+
if (decrease && args.filter(a => Math.abs(a) > .5).length === 0) {
|
|
26
|
+
spd.reset();
|
|
27
|
+
_decrease();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (args.filter(a => Math.abs(a) > .1).length === 0) {
|
|
31
|
+
spd.reset();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
var id = smooth_timer;
|
|
35
|
+
var res = gun.apply(that, args);
|
|
36
|
+
if (id !== smooth_timer) return;
|
|
37
|
+
if (false === res) {
|
|
38
|
+
spd.reset();
|
|
39
|
+
smooth_timer = requestAnimationFrame(_decrease);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
smooth_timer = requestAnimationFrame(smooth);
|
|
43
|
+
};
|
|
44
|
+
var spd, smooth_timer, that, decrease;
|
|
45
|
+
var train = function () {
|
|
46
|
+
_cancel();
|
|
47
|
+
var args = [].slice.call(arguments, 0, arguments.length);
|
|
48
|
+
spd.write(args);
|
|
49
|
+
gun.apply(this, args);
|
|
50
|
+
that = this;
|
|
51
|
+
};
|
|
52
|
+
train.smooth = function (d) {
|
|
53
|
+
_cancel();
|
|
54
|
+
decrease = d;
|
|
55
|
+
smooth_timer = requestAnimationFrame(smooth);
|
|
56
|
+
};
|
|
57
|
+
train.reset = function () {
|
|
58
|
+
_cancel();
|
|
59
|
+
spd.reset();
|
|
60
|
+
};
|
|
61
|
+
return train;
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
class Speed extends Array {
|
|
65
|
+
cache = [];
|
|
66
|
+
stamp = 0;
|
|
67
|
+
static now() {
|
|
68
|
+
return performance.now ? performance.now() : Date.now();
|
|
69
|
+
}
|
|
70
|
+
static inertia = inertia;
|
|
71
|
+
reset() {
|
|
72
|
+
this.cache.splice(0, this.cache.length, 0);
|
|
73
|
+
}
|
|
74
|
+
unset() {
|
|
75
|
+
this.splice(0, this.length), this.cache.splice(0, this.cache.length), this.stamp = 0;
|
|
76
|
+
}
|
|
77
|
+
write(values, stamp = Speed.now()) {
|
|
78
|
+
if (values.length !== this.length || this.length && this.cache.length < 2) this.unset();
|
|
79
|
+
this.cache.push(values, stamp);
|
|
80
|
+
if (this.cache.length > 20) this.cache.splice(0, 12);
|
|
81
|
+
var start = Math.max(this.cache.length - 6, 0);
|
|
82
|
+
var s = values.slice(0, values.length), t = this.cache[this.cache.length - 1] - this.cache[start + 1] + 12;
|
|
83
|
+
for (var cx = start, dx = this.cache.length - 2; cx < dx; cx++) {
|
|
84
|
+
var values = this.cache[cx++];
|
|
85
|
+
for (var cy = 0, dy = values.length; cy < dy; cy++) {
|
|
86
|
+
var v = values[cy];
|
|
87
|
+
if (!s[cy]) s[cy] = 0;
|
|
88
|
+
s[cy] += v;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
for (var cx = 0, dx = s.length; cx < dx; cx++) {
|
|
92
|
+
this[cx] = s[cx] / t;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
read(now = Speed.now()) {
|
|
96
|
+
var stamp = this.cache[this.cache.length - 1];
|
|
97
|
+
var values = this.slice(0);
|
|
98
|
+
var deltat = now - stamp;
|
|
99
|
+
var ratio;
|
|
100
|
+
if (this.stamp) ratio = now - this.stamp;
|
|
101
|
+
else ratio = deltat;
|
|
102
|
+
if (ratio > 160) ratio = 1e-3;
|
|
103
|
+
this.stamp = now;
|
|
104
|
+
var sum = 0;
|
|
105
|
+
for (var v of values) sum += v * v;
|
|
106
|
+
v = Math.sqrt(sum) * ratio;
|
|
107
|
+
if (v > 1) {
|
|
108
|
+
v = Math.sqrt(v * (v - 1)) / v;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
v = 1e-7;
|
|
112
|
+
}
|
|
113
|
+
var r = ratio * v;
|
|
114
|
+
for (var cx = 0, dx = values.length; cx < dx; cx++) {
|
|
115
|
+
values[cx] *= r;
|
|
116
|
+
this[cx] *= v;
|
|
117
|
+
}
|
|
118
|
+
return values;
|
|
119
|
+
}
|
|
120
|
+
}
|
package/coms/basic/assert.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
var
|
|
1
|
+
var dump = function (a) {
|
|
2
|
+
if (a instanceof Object) console.error('对象的属性不符合'), console.log(" ", a);
|
|
3
|
+
else console.error(a);
|
|
4
|
+
};
|
|
5
|
+
var assert = function (result, expect, log = dump) {
|
|
2
6
|
var errors = {}, hasCollect;
|
|
3
7
|
var collect = function (k, args) {
|
|
4
8
|
hasCollect = true;
|
|
@@ -19,7 +23,12 @@ var assert = function (result, expect, log = console.error) {
|
|
|
19
23
|
var res = false;
|
|
20
24
|
if (result === expect) {
|
|
21
25
|
res = true;
|
|
22
|
-
}
|
|
26
|
+
}
|
|
27
|
+
else if (typeof result === "number" && typeof expect === "number") {
|
|
28
|
+
var e = (result - expect) * (result - expect) / Math.sqrt(result * result + expect * expect);
|
|
29
|
+
if (e < 1e-14) res = true;
|
|
30
|
+
}
|
|
31
|
+
else if (expect instanceof Date) {
|
|
23
32
|
if (result instanceof Date)
|
|
24
33
|
res = assert(+expect, +result, collect());
|
|
25
34
|
} else if (expect instanceof Array) {
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
// 空间变换算法
|
|
2
|
+
// function [dots]=xrs(dots,wyh)
|
|
3
|
+
// % 转动,缩放,平移,依次进行
|
|
4
|
+
// % wyh.mid为变换中心
|
|
5
|
+
// % wyh.ppt为转动轴的方向
|
|
6
|
+
// % wyh.alph为转动角度
|
|
7
|
+
// % wyh.scrl为缩放系数,反射可设轴向系数为-1
|
|
8
|
+
// % wyh.drag为平移向量
|
|
9
|
+
// wyh.alph=pi*wyh.alph/180;
|
|
10
|
+
// if size(dots,2)==3
|
|
11
|
+
// if numel(wyh.ppt) == 2
|
|
12
|
+
// theta = pi*wyh.ppt(1)/180;
|
|
13
|
+
// phi = pi*wyh.ppt(2)/180;
|
|
14
|
+
// rot_u = [cos(phi)*cos(theta); cos(phi)*sin(theta); sin(phi)];
|
|
15
|
+
// elseif numel(wyh.ppt) == 3
|
|
16
|
+
// rot_u = wyh.ppt(:)/norm(wyh.ppt);
|
|
17
|
+
// end
|
|
18
|
+
// x_u = rot_u(1);
|
|
19
|
+
// y_u = rot_u(2);
|
|
20
|
+
// z_u = rot_u(3);
|
|
21
|
+
// cosa = cos(wyh.alph);
|
|
22
|
+
// sina = sin(wyh.alph);
|
|
23
|
+
// vera = 1 - cosa;
|
|
24
|
+
// rot = [cosa+x_u^2*vera x_u*y_u*vera-z_u*sina x_u*z_u*vera+y_u*sina; ...
|
|
25
|
+
// x_u*y_u*vera+z_u*sina cosa+y_u^2*vera y_u*z_u*vera-x_u*sina; ...
|
|
26
|
+
// x_u*z_u*vera-y_u*sina y_u*z_u*vera+x_u*sina cosa+z_u^2*vera]';
|
|
27
|
+
// else
|
|
28
|
+
// rot=[cos(wyh.alph),-sin(wyh.alph);sin(wyh.alph),cos(wyh.alph)];
|
|
29
|
+
// end
|
|
30
|
+
// for cx=1:size(dots,1)
|
|
31
|
+
// dots(cx,:)=(dots(cx,:)-wyh.mid).*wyh.scrl*rot+wyh.mid+wyh.drag;
|
|
32
|
+
// end
|
|
33
|
+
// end
|
|
34
|
+
"use strict";
|
|
35
|
+
|
|
36
|
+
var notMatchLength = new Error("矩阵长度不一致");
|
|
37
|
+
function transform(dots, B) {
|
|
38
|
+
var dimention = Math.sqrt(B.length - 1) | 0;
|
|
39
|
+
if (dots.length % dimention !== 0) throw notMatchLength;
|
|
40
|
+
if (dots === B) B = B.slice(0);
|
|
41
|
+
var ds = dots.slice(0);
|
|
42
|
+
var dim2 = B.length % dimention !== 0 ? dimention + 1 : dimention;
|
|
43
|
+
for (var cx = 0, dx = dots.length; cx < dx; cx += dimention) {
|
|
44
|
+
for (var cy = 0, dy = dimention; cy < dy; cy++) {
|
|
45
|
+
var sum = 0;
|
|
46
|
+
for (var ct = 0, dt = dimention; ct < dt; ct++) {
|
|
47
|
+
sum += ds[cx + ct] * B[ct * dim2 + cy];
|
|
48
|
+
}
|
|
49
|
+
sum += B[dimention * dim2 + cy];
|
|
50
|
+
dots[cx + cy] = sum;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return dots;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function translate(A, delta) {
|
|
57
|
+
var [dim2, dim] = size(A);
|
|
58
|
+
var inc = 0;
|
|
59
|
+
for (var cx = dim * dim2, dx = cx + dim; cx < dx; cx++) {
|
|
60
|
+
A[cx] = (A[cx] || 0) + delta[inc++];
|
|
61
|
+
}
|
|
62
|
+
return A;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
function 负(a) {
|
|
67
|
+
return -a;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function multiply(A, B) {
|
|
71
|
+
if (A.length !== B.length) throw notMatchLength;
|
|
72
|
+
var dim = Math.sqrt(A.length) | 0;
|
|
73
|
+
if (dim * dim !== A.length) throw notMatchLength;
|
|
74
|
+
var X = A.slice(0);
|
|
75
|
+
for (var cx = 0, dx = A.length; cx < dx; cx += dim) {
|
|
76
|
+
for (var cy = 0, dy = dim; cy < dy; cy++) {
|
|
77
|
+
var sum = 0;
|
|
78
|
+
for (var ct = 0, dt = dim; ct < dt; ct++) {
|
|
79
|
+
sum += X[cx + ct] * B[ct * dim + cy];
|
|
80
|
+
}
|
|
81
|
+
A[cx + cy] = sum;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return A;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function inner(vec1, vec2) {
|
|
88
|
+
if (vec1.length !== vec2.length) throw notMatchLength;
|
|
89
|
+
var sum = 0;
|
|
90
|
+
for (var cx = 0, dx = vec1.length; cx < dx; cx++) {
|
|
91
|
+
sum += vec1[cx] * vec2[cx];
|
|
92
|
+
}
|
|
93
|
+
return sum;
|
|
94
|
+
}
|
|
95
|
+
function cross(vec1, vec2) {
|
|
96
|
+
if (vec1.length !== vec2.length) throw notMatchLength;
|
|
97
|
+
var c = new Array(vec1.length);
|
|
98
|
+
for (var cx = 0, dx = vec1.length; cx < dx; cx++) {
|
|
99
|
+
var s = 0, f = 1;
|
|
100
|
+
for (var cy = 1, dy = dx; cy < dy; cy++) {
|
|
101
|
+
var c1 = cx + cy;
|
|
102
|
+
var c2 = c1 + f;
|
|
103
|
+
if (c1 >= dx) c1 -= dx;
|
|
104
|
+
if (c2 >= dx) c2 -= dx;
|
|
105
|
+
f = 0 - f;
|
|
106
|
+
s += vec1[c1] * vec2[c2];
|
|
107
|
+
}
|
|
108
|
+
c[cx] = s;
|
|
109
|
+
}
|
|
110
|
+
return c;
|
|
111
|
+
}
|
|
112
|
+
function times(vector, factor) {
|
|
113
|
+
for (var cx = 0, dx = vector.length; cx < dx; cx++) {
|
|
114
|
+
vector[cx] *= factor;
|
|
115
|
+
}
|
|
116
|
+
return vector;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function olinde(v, vector) {
|
|
120
|
+
// 罗德里格旋转公式
|
|
121
|
+
// https://baike.baidu.com/item/%E7%BD%97%E5%BE%B7%E9%87%8C%E6%A0%BC%E6%97%8B%E8%BD%AC%E5%85%AC%E5%BC%8F/18878562
|
|
122
|
+
// https://www.cnblogs.com/flyinggod/p/8144100.html 旋转矩阵、欧拉角、四元数理论及其转换关系
|
|
123
|
+
var theta = norm(vector);
|
|
124
|
+
var k = times(vector.slice(0), 1 / theta);
|
|
125
|
+
var cosa = Math.cos(theta);
|
|
126
|
+
var sina = Math.sin(theta);
|
|
127
|
+
var inna = inner(k, v);
|
|
128
|
+
var aa = inna * (1 - cosa);
|
|
129
|
+
var kv = cross(k, v);
|
|
130
|
+
for (var cx = 0, dx = k.length; cx < dx; cx++) {
|
|
131
|
+
v[cx] = v[cx] * cosa + aa * k[cx] + sina * kv[cx];
|
|
132
|
+
}
|
|
133
|
+
return v;
|
|
134
|
+
}
|
|
135
|
+
function matrix2d(theta) {
|
|
136
|
+
var cosa = Math.cos(theta);
|
|
137
|
+
var sina = Math.sin(theta);
|
|
138
|
+
return new Matrix(
|
|
139
|
+
cosa, sina, 0,
|
|
140
|
+
-sina, cosa, 0,
|
|
141
|
+
0, 0, 1
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
function matrix3d(factor) {
|
|
145
|
+
var theta = norm(factor);
|
|
146
|
+
var vec = times(factor, 1 / theta);
|
|
147
|
+
var cosa = Math.cos(theta);
|
|
148
|
+
var sina = Math.sin(theta);
|
|
149
|
+
var vera = 1 - cosa;
|
|
150
|
+
var [x_u, y_u, z_u] = factor ? [0, 0, 1] : vec;
|
|
151
|
+
|
|
152
|
+
return new Matrix(
|
|
153
|
+
cosa + x_u * x_u * vera, x_u * y_u * vera - z_u * sina, x_u * z_u * vera + y_u * sina, 0,
|
|
154
|
+
x_u * y_u * vera + z_u * sina, cosa + y_u * y_u * vera, y_u * z_u * vera - x_u * sina, 0,
|
|
155
|
+
x_u * z_u * vera - y_u * sina, y_u * z_u * vera + x_u * sina, cosa + z_u * z_u * vera, 0,
|
|
156
|
+
0, 0, 0, 1
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
var norm = function (vector) {
|
|
160
|
+
var sum = 0;
|
|
161
|
+
for (var cx = 0, dx = vector.length; cx < dx; cx++) {
|
|
162
|
+
sum += vector[cx] * vector[cx];
|
|
163
|
+
}
|
|
164
|
+
return Math.sqrt(sum);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
var 逆 = function (A) {
|
|
168
|
+
var dim = Math.sqrt(A.length) | 0;
|
|
169
|
+
if (dim * dim !== A.length) throw notMatchLength;
|
|
170
|
+
var E = new Array(A.length).fill(0);
|
|
171
|
+
for (var cx = 0, dx = dim; cx < dx; cx++)E[cx * dim + cx] = 1;
|
|
172
|
+
var X = A.splice(0, A.length);
|
|
173
|
+
A.push.apply(A, E);
|
|
174
|
+
for (var cx = 0, dx = dim; cx < dx; cx++) {
|
|
175
|
+
var start = cx * dim + cx;
|
|
176
|
+
for (var ct = start, dt = X.length; ct < dt; ct += dim) {
|
|
177
|
+
if (X[ct] !== 0) break;
|
|
178
|
+
}
|
|
179
|
+
if (ct !== start) {
|
|
180
|
+
var delta = ct - start;
|
|
181
|
+
var ratio = 1 / X[ct];
|
|
182
|
+
for (var cy = cx * dim, dy = cy + dim; cy < dy; cy++) {
|
|
183
|
+
X[cy] += X[cy + delta] * ratio;
|
|
184
|
+
A[cy] += A[cy + delta] * ratio;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (X[start] !== 1) {
|
|
188
|
+
var delta = ct - start;
|
|
189
|
+
var ratio = 1 / X[start];
|
|
190
|
+
for (var cy = cx * dim, dy = cy + dim; cy < dy; cy++) {
|
|
191
|
+
X[cy] *= ratio;
|
|
192
|
+
A[cy] *= ratio;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
for (var ct = start + dim, dt = X.length; ct < dt; ct += dim) {
|
|
196
|
+
if (X[ct] === 0) continue;
|
|
197
|
+
var ratio = -X[ct];
|
|
198
|
+
var delta = start - ct;
|
|
199
|
+
for (var cy = ct - cx, dy = cy + dim; cy < dy; cy++) {
|
|
200
|
+
X[cy] += X[cy + delta] * ratio;
|
|
201
|
+
A[cy] += A[cy + delta] * ratio;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
for (var cx = dim - 2; cx >= 0; cx--) {
|
|
206
|
+
var start = cx * dim + cx + 1;
|
|
207
|
+
for (var ct = start; ct >= 0; ct -= dim) {
|
|
208
|
+
if (X[ct] === 0) continue;
|
|
209
|
+
var ratio = -X[ct];
|
|
210
|
+
var delta = dim + start - ct;
|
|
211
|
+
for (var cy = cx * dim, dy = cy + dim; cy < dy; cy++) {
|
|
212
|
+
X[cy] += X[cy + delta] * ratio;
|
|
213
|
+
A[cy] += A[cy + delta] * ratio;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return A;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
function size(A) {
|
|
221
|
+
var dim = Math.sqrt(A.length - 1) | 0;
|
|
222
|
+
var dim2 = dim;
|
|
223
|
+
if (A.length % dim !== 0) {
|
|
224
|
+
dim2++;
|
|
225
|
+
}
|
|
226
|
+
if ((dim + 1) * dim2 !== A.length) throw notMatchLength;
|
|
227
|
+
return [dim2, dim];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
class Matrix extends Array {
|
|
231
|
+
static create2d(theta = 0) {
|
|
232
|
+
return matrix2d(theta);
|
|
233
|
+
}
|
|
234
|
+
static create3d(factor = [0, 0, 0]) {
|
|
235
|
+
return matrix3d(factor);
|
|
236
|
+
}
|
|
237
|
+
size() {
|
|
238
|
+
return size(this);
|
|
239
|
+
}
|
|
240
|
+
dirty() {
|
|
241
|
+
this._invert = null;
|
|
242
|
+
}
|
|
243
|
+
_invert = null;
|
|
244
|
+
get invert() {
|
|
245
|
+
if (this._invert) return this._invert;
|
|
246
|
+
return this._invert = this.slice().inverse();
|
|
247
|
+
}
|
|
248
|
+
inverse() {
|
|
249
|
+
this.dirty();
|
|
250
|
+
return 逆(this);
|
|
251
|
+
}
|
|
252
|
+
rotate(factor, center) {
|
|
253
|
+
this.dirty();
|
|
254
|
+
if (center) this.translate(center.map(负));
|
|
255
|
+
if (factor.length) {
|
|
256
|
+
this.multiply(matrix3d(factor));
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
this.multiply(matrix2d(factor));
|
|
260
|
+
}
|
|
261
|
+
if (center) this.translate(center);
|
|
262
|
+
return this;
|
|
263
|
+
}
|
|
264
|
+
translate(vector) {
|
|
265
|
+
this.dirty();
|
|
266
|
+
return translate(this, vector);
|
|
267
|
+
}
|
|
268
|
+
scale(ratio) {
|
|
269
|
+
this.dirty();
|
|
270
|
+
times(this, ratio);
|
|
271
|
+
this[this.length - 1] = 1;
|
|
272
|
+
return this;
|
|
273
|
+
}
|
|
274
|
+
multiply(a) {
|
|
275
|
+
this.dirty();
|
|
276
|
+
return multiply(this, a);
|
|
277
|
+
}
|
|
278
|
+
transform(dots) {
|
|
279
|
+
if (dots instanceof Array) return transform(dots, this);
|
|
280
|
+
if (isFinite(dots)) return dots * this[this.length - 1];
|
|
281
|
+
return dots;
|
|
282
|
+
}
|
|
283
|
+
}
|
package/coms/basic/parseYML.js
CHANGED
|
@@ -75,7 +75,8 @@ var scan = function (text) {
|
|
|
75
75
|
}
|
|
76
76
|
data += row.slice(0, index + +!!jsonlikes.length);
|
|
77
77
|
row = row.slice(index + 1)
|
|
78
|
-
|
|
78
|
+
if (!row) push();
|
|
79
|
+
else unshift(spacesize, row);
|
|
79
80
|
rowtype = 0;
|
|
80
81
|
continue;
|
|
81
82
|
}
|
|
@@ -187,15 +188,16 @@ var scan = function (text) {
|
|
|
187
188
|
continue;
|
|
188
189
|
}
|
|
189
190
|
else {
|
|
190
|
-
var match = /^([\s\S]
|
|
191
|
+
var match = /^([\s\S]+)?\:(|\s+[\s\S]*)$/.exec(row);
|
|
191
192
|
if (match) {
|
|
192
|
-
if (data || prop && span >= spacesize) push();
|
|
193
|
+
if (data && !!match[1] || prop && span >= spacesize) push();
|
|
193
194
|
if (prop) {
|
|
194
195
|
var obj = {};
|
|
195
196
|
push(obj);
|
|
196
197
|
parents[spacesize] = obj;
|
|
197
198
|
}
|
|
198
199
|
var [_, prop, value] = match;
|
|
200
|
+
if (!prop) prop = data, data = '';
|
|
199
201
|
value = value.trim();
|
|
200
202
|
if (value) {
|
|
201
203
|
unshift(spacesize + 1, value);
|
package/coms/compile/common.js
CHANGED
|
@@ -122,6 +122,7 @@ var createScoped = function (parsed, wash) {
|
|
|
122
122
|
var isArrow = false;
|
|
123
123
|
var isDeclare = false;
|
|
124
124
|
var isYield = false;
|
|
125
|
+
var isClass = false;
|
|
125
126
|
switch (o.type) {
|
|
126
127
|
case QUOTED:
|
|
127
128
|
if (o.length) {
|
|
@@ -215,8 +216,9 @@ var createScoped = function (parsed, wash) {
|
|
|
215
216
|
o = o.next;
|
|
216
217
|
}
|
|
217
218
|
case "catch":
|
|
218
|
-
isCatch = true;
|
|
219
|
+
if (s === 'catch') isCatch = true;
|
|
219
220
|
case "class":
|
|
221
|
+
if (s === 'class') isClass = true;
|
|
220
222
|
if (!o.isExpress) {
|
|
221
223
|
o = o.next;
|
|
222
224
|
|
|
@@ -225,7 +227,6 @@ var createScoped = function (parsed, wash) {
|
|
|
225
227
|
isDeclare = true;
|
|
226
228
|
o.kind = isFunction ? 'function' : 'class';
|
|
227
229
|
saveTo(used, o.text, o);
|
|
228
|
-
|
|
229
230
|
o = o.next;
|
|
230
231
|
}
|
|
231
232
|
}
|
|
@@ -286,6 +287,9 @@ var createScoped = function (parsed, wash) {
|
|
|
286
287
|
vars = _vars;
|
|
287
288
|
scoped.lets = lets;
|
|
288
289
|
scoped.used = used;
|
|
290
|
+
if (isClass) {
|
|
291
|
+
lets.super = true;
|
|
292
|
+
}
|
|
289
293
|
}
|
|
290
294
|
if (isArrow);
|
|
291
295
|
else if (o.isExpress && o.type !== SCOPED && !isDeclare) {
|
|
@@ -216,8 +216,8 @@ var hooka = function (matcher, move, event, targetChild, isMovingSource) {
|
|
|
216
216
|
var dstElement = children[dst + delta];
|
|
217
217
|
src = bindTarget(src, srcElement);
|
|
218
218
|
dst = bindTarget(dst, dstElement);
|
|
219
|
-
isFunction(move)
|
|
220
|
-
if (srcElement === children[src] && dstElement === children[dst + delta] && srcElement && dstElement) appendSibling(dstElement, srcElement);
|
|
219
|
+
var needFire = !isFunction(move) || move(src, dst, dst + delta, appendSibling, targetBox) !== false;
|
|
220
|
+
if (needFire && srcElement === children[src] && dstElement === children[dst + delta] && srcElement && dstElement) appendSibling(dstElement, srcElement);
|
|
221
221
|
} else if (isMovingSource === false) {
|
|
222
222
|
move(previousElements.length, previousElements.length, previousElements.length, null, targetBox);
|
|
223
223
|
}
|
package/coms/zimoli/confirm.js
CHANGED
|
@@ -123,9 +123,6 @@ function confirm() {
|
|
|
123
123
|
onclick(btn, clickbtn);
|
|
124
124
|
return btn;
|
|
125
125
|
});
|
|
126
|
-
onclick(element, function () {
|
|
127
|
-
css(this, { zIndex: zIndex() });
|
|
128
|
-
});
|
|
129
126
|
preventOverflowScrolling(element);
|
|
130
127
|
appendChild(option, buttons);
|
|
131
128
|
if (!target) element.initialStyle = "transform:scale(0.96);opacity:0;transition:transform .3s,opacity .2s ease-out";
|
package/coms/zimoli/data.js
CHANGED
|
@@ -314,10 +314,12 @@ function parseConfig(api) {
|
|
|
314
314
|
var isWorseIE = /msie\s+[2-9]/i.test(navigator.userAgent);
|
|
315
315
|
var parseData = function (sourceText) {
|
|
316
316
|
if (/^\s*<[^\s\'\"\`]/i.test(sourceText)) {
|
|
317
|
+
if (!isWorseIE && window.DOMParser) {
|
|
318
|
+
return new window.DOMParser().parseFromString(sourceText, "text/html");
|
|
319
|
+
}
|
|
317
320
|
// XML 格式
|
|
318
321
|
var doc = document.implementation.createHTMLDocument('');
|
|
319
322
|
if (isWorseIE) {
|
|
320
|
-
|
|
321
323
|
sourceText = sourceText
|
|
322
324
|
.replace(/<!--[\s\S]*?-->|<\[CDATA\[[\s\S]*?\]\]>/ig, '')
|
|
323
325
|
.replace(/^[\s\S]*?<html>([\s\S]*)<\/html>[\s\S]*?$/i, '$1')
|
package/coms/zimoli/drag.js
CHANGED
|
@@ -13,6 +13,22 @@ var getOffset = function (e) {
|
|
|
13
13
|
if (isFinite(e.screenLeft)) return [e.screenLeft, e.screenTop];
|
|
14
14
|
if (isFinite(e.screenX)) return [e.screenX, e.screenY];
|
|
15
15
|
};
|
|
16
|
+
var z;
|
|
17
|
+
var addZIndex = function (clone) {
|
|
18
|
+
if (clone.style) clone.style.zIndex = z + (+clone.style.zIndex || 0);
|
|
19
|
+
};
|
|
20
|
+
var setZIndex = function () {
|
|
21
|
+
var target = this;
|
|
22
|
+
if (!isElement(target)) return;
|
|
23
|
+
var computed = getComputedStyle(target);
|
|
24
|
+
var z0 = zIndex(0);
|
|
25
|
+
if (!z || computed.zIndex < z0) {
|
|
26
|
+
z = zIndex();
|
|
27
|
+
if (/^(absolute|fixed)$/i.test(computed.position)) {
|
|
28
|
+
css(target, { zIndex: z });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
16
32
|
function drag(target, initialEvent, preventOverflow, isMovingSource) {
|
|
17
33
|
if (/^(?:select|input|textarea)$/i.test(initialEvent.target.tagName)) return;
|
|
18
34
|
if (target.dragable === false) return;
|
|
@@ -36,7 +52,6 @@ function drag(target, initialEvent, preventOverflow, isMovingSource) {
|
|
|
36
52
|
var saved_height = target.outerHeight;
|
|
37
53
|
}
|
|
38
54
|
var extraClones;
|
|
39
|
-
|
|
40
55
|
var mousemove = function (event) {
|
|
41
56
|
if (event.moveLocked) return;
|
|
42
57
|
if (/resize/i.test(getComputedStyle(document.body).cursor)) return;
|
|
@@ -50,21 +65,20 @@ function drag(target, initialEvent, preventOverflow, isMovingSource) {
|
|
|
50
65
|
dispatch("dragstart", target);
|
|
51
66
|
if (isElement(target) && !/absolute|fixed/.test(getComputedStyle(target).position)) {
|
|
52
67
|
clone = toCloneTarget(target, isMovingSource);
|
|
68
|
+
z = zIndex(0) + 1;
|
|
69
|
+
addZIndex(clone);
|
|
53
70
|
appendChild(document.body, clone);
|
|
54
71
|
} else {
|
|
55
72
|
clone = target;
|
|
56
73
|
extraTargets = [];
|
|
74
|
+
if (target.style) css(target, { zIndex: z });
|
|
57
75
|
}
|
|
58
76
|
var [clone_left, clone_top] = getOffset(clone);
|
|
59
77
|
extraClones = extraTargets.map(toCloneTarget);
|
|
78
|
+
extraClones.forEach(addZIndex);
|
|
60
79
|
extraClones.map(c => document.body.appendChild(c));
|
|
61
80
|
saved_delta.x += clone_left - target_left;
|
|
62
81
|
saved_delta.y += clone_top - target_top;
|
|
63
|
-
if (clone.style) {
|
|
64
|
-
var z = zIndex();
|
|
65
|
-
clone.style.zIndex = z + (+clone.style.zIndex || 0);
|
|
66
|
-
extraClones.map(e => e.style.zIndex = z + (+e.style.zIndex || 0));
|
|
67
|
-
}
|
|
68
82
|
}
|
|
69
83
|
drag.target = clone;
|
|
70
84
|
var offsetLeft = saved_delta.x + event.screenX;
|
|
@@ -125,6 +139,9 @@ drag.on = function (target, actionTarget = target.dragTarget) {
|
|
|
125
139
|
var _mousedrag = mousedrag;
|
|
126
140
|
var _touchdrag = touchdrag;
|
|
127
141
|
}
|
|
142
|
+
onmousedown(actionTarget || target, setZIndex);
|
|
143
|
+
ontouchstart(actionTarget || target, setZIndex);
|
|
144
|
+
on("drop")(actionTarget || target, setZIndex);
|
|
128
145
|
onmousedown(target, _mousedrag);
|
|
129
146
|
ontouchstart(target, _touchdrag);
|
|
130
147
|
move.bindPosition(actionTarget || target);
|
package/coms/zimoli/inertia.js
CHANGED
|
@@ -1,70 +1 @@
|
|
|
1
|
-
|
|
2
|
-
function main(gun, is_delta = true) {
|
|
3
|
-
var smooth = function () {
|
|
4
|
-
var currentTime = +new Date;
|
|
5
|
-
var delta_time = currentTime - savedTime;
|
|
6
|
-
|
|
7
|
-
savedTime = currentTime;
|
|
8
|
-
if (delta_time > 6) {
|
|
9
|
-
var abs_speed = 0;
|
|
10
|
-
var args = speeds.map(function (_speed, i) {
|
|
11
|
-
var __speed = _speed() * delta_time;
|
|
12
|
-
var abs_spd = abs(__speed);
|
|
13
|
-
if (abs_spd <= 1) {
|
|
14
|
-
return _speed(0);
|
|
15
|
-
}
|
|
16
|
-
abs_speed = Math.max(abs_speed, abs_spd);
|
|
17
|
-
__speed = __speed - sign(__speed) * (abs_spd - sqrt(abs_spd) * sqrt(abs_spd - 1));
|
|
18
|
-
_speed(__speed);
|
|
19
|
-
return __speed;
|
|
20
|
-
});
|
|
21
|
-
run(args);
|
|
22
|
-
if (!(abs_speed >= 1)) {
|
|
23
|
-
if (
|
|
24
|
-
decrease instanceof Function
|
|
25
|
-
) decrease();
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
smooth_timer = requestAnimationFrame(smooth);
|
|
30
|
-
};
|
|
31
|
-
var run = function (args) {
|
|
32
|
-
if (false === gun.apply(that, args)) {
|
|
33
|
-
speeds.forEach(a => a(0));
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var saved_args, speeds, smooth_timer, savedTime = 0, that, decrease;
|
|
37
|
-
var trans = function () {
|
|
38
|
-
cancelAnimationFrame(smooth_timer);
|
|
39
|
-
var args = arguments;
|
|
40
|
-
if (!saved_args) {
|
|
41
|
-
saved_args = args;
|
|
42
|
-
speeds = [].map.call(saved_args, a => speed());
|
|
43
|
-
speeds.forEach(a => a(0));
|
|
44
|
-
savedTime = +new Date;
|
|
45
|
-
} else if (args.length !== saved_args.length) {
|
|
46
|
-
saved_args = null;
|
|
47
|
-
// throw new Error("前后传入的参数的个数应该相同!");
|
|
48
|
-
} else {
|
|
49
|
-
if (!is_delta) {
|
|
50
|
-
args = [].map.call(args, (a, i) => a - saved_args[i]);
|
|
51
|
-
}
|
|
52
|
-
that = this;
|
|
53
|
-
run(args);
|
|
54
|
-
args = speeds.map((a, i) => a(args[i]));
|
|
55
|
-
savedTime = +new Date;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
trans.smooth = function (d) {
|
|
59
|
-
decrease = d;
|
|
60
|
-
if (speeds) smooth_timer = requestAnimationFrame(smooth, 20);
|
|
61
|
-
else decrease();
|
|
62
|
-
};
|
|
63
|
-
trans.reset = function () {
|
|
64
|
-
cancelAnimationFrame(smooth_timer);
|
|
65
|
-
saved_args = null;
|
|
66
|
-
speeds = null;
|
|
67
|
-
decrease = null;
|
|
68
|
-
};
|
|
69
|
-
return trans;
|
|
70
|
-
}
|
|
1
|
+
Speed.inertia;
|