efront 4.22.11 → 4.22.13
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/#/345/233/275/351/231/205/345/214/226.yml +3 -0
- package/apps/_index.html +4 -0
- package/coms/basic/Comb.js +68 -0
- package/coms/basic/Speed.js +13 -2
- package/coms/basic/combgen.js +6 -16
- package/coms/basic/combine.js +6 -16
- package/coms/zimoli/autodragchildren.js +2 -1
- package/coms/zimoli/getGenerator.js +4 -2
- package/coms/zimoli/list.js +35 -16
- package/coms/zimoli/list.less +4 -0
- package/coms/zimoli/model.js +2 -2
- package/coms/zimoli/render.js +32 -28
- package/coms/zimoli/tree.js +2 -2
- package/coms/zimoli/vbox.js +7 -2
- package/coms/zimoli/view.less +1 -1
- package/coms//350/214/250/350/217/260//346/240/207/347/255/276/345/214/226.js +18 -12
- package/docs//347/273/204/344/273/266.xht +0 -1
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/apps/_index.html
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
function combgeta(args) {
|
|
2
|
+
if (typeof args[0] === "function") return [args[0], Array.prototype.slice.call(args, 1)];
|
|
3
|
+
if (typeof args[args.length - 1] === "function") return [args[args.length - 1], Array.prototype.slice.call(args, 0, args.length - 1)];
|
|
4
|
+
return [null, args];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function getRatiosList(argsList, total) {
|
|
8
|
+
return argsList.map(a => total = total / a.length);
|
|
9
|
+
}
|
|
10
|
+
function rangeAt(i) {
|
|
11
|
+
if (i < 0 || i > this.length) return;
|
|
12
|
+
var { source, ratios, format } = this;
|
|
13
|
+
var args = source.map(function (a, cx) {
|
|
14
|
+
var index = i / ratios[cx] | 0;
|
|
15
|
+
i = i - index * ratios[cx];
|
|
16
|
+
return a.start + index * a.step;
|
|
17
|
+
});
|
|
18
|
+
if (format) format(args);
|
|
19
|
+
return args;
|
|
20
|
+
}
|
|
21
|
+
function itemAt(i) {
|
|
22
|
+
if (i < 0 || i > this.length) return;
|
|
23
|
+
var { source, ratios, format } = this;
|
|
24
|
+
var args = source.map(function (a, cx) {
|
|
25
|
+
var index = i / ratios[cx] | 0;
|
|
26
|
+
i = i - index * ratios[cx];
|
|
27
|
+
return a[index];
|
|
28
|
+
});
|
|
29
|
+
if (format) args = format(args);
|
|
30
|
+
return args;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class Comb {
|
|
34
|
+
static args = combgeta;
|
|
35
|
+
constructor() {
|
|
36
|
+
var f, args, srcIsRange;
|
|
37
|
+
for (var a of arguments) {
|
|
38
|
+
switch (typeof a) {
|
|
39
|
+
case "boolean": srcIsRange = a; break;
|
|
40
|
+
case "object": args = a; break;
|
|
41
|
+
case "function": f = a; break;
|
|
42
|
+
default: throw new Error(i18n`参数异常: ${a}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
this.format = f;
|
|
47
|
+
var total = 1;
|
|
48
|
+
if (srcIsRange) {
|
|
49
|
+
this.source = Array.prototype.map.call(args, a => {
|
|
50
|
+
var [s, e, t = 1] = a;
|
|
51
|
+
var r = (1 + e - s) / t;
|
|
52
|
+
total *= r;
|
|
53
|
+
return { length: r, start: s, end: e, step: t };
|
|
54
|
+
});
|
|
55
|
+
this.get = rangeAt;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.source = Array.prototype.map.call(args, a => {
|
|
59
|
+
total *= a.length;
|
|
60
|
+
return a;
|
|
61
|
+
});
|
|
62
|
+
this.get = itemAt;
|
|
63
|
+
}
|
|
64
|
+
this.ratios = getRatiosList(this.source, total);
|
|
65
|
+
this.length = total;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
module.exports = Comb;
|
package/coms/basic/Speed.js
CHANGED
|
@@ -14,6 +14,11 @@ function inertia(gun) {
|
|
|
14
14
|
lastTime = Speed.now() - 1;
|
|
15
15
|
_decrease0();
|
|
16
16
|
}
|
|
17
|
+
var park = function () {
|
|
18
|
+
train.state = 停止;
|
|
19
|
+
if (isFunction(train.park)) train.park();
|
|
20
|
+
};
|
|
21
|
+
|
|
17
22
|
var _decrease0 = function () {
|
|
18
23
|
if (
|
|
19
24
|
decrease instanceof Function
|
|
@@ -26,11 +31,14 @@ function inertia(gun) {
|
|
|
26
31
|
if (smooth_timer !== id) return;
|
|
27
32
|
if (res === false || isEmpty(res)) {
|
|
28
33
|
spd.unset();
|
|
29
|
-
|
|
34
|
+
park();
|
|
30
35
|
return;
|
|
31
36
|
}
|
|
32
37
|
smooth_timer = requestAnimationFrame(_decrease0);
|
|
33
38
|
}
|
|
39
|
+
else {
|
|
40
|
+
park();
|
|
41
|
+
}
|
|
34
42
|
};
|
|
35
43
|
var _cancel = function () {
|
|
36
44
|
cancelAnimationFrame(smooth_timer);
|
|
@@ -50,7 +58,7 @@ function inertia(gun) {
|
|
|
50
58
|
}
|
|
51
59
|
if (args.stop || rate && args.rate < rate) {
|
|
52
60
|
if (!decrease) {
|
|
53
|
-
|
|
61
|
+
park();
|
|
54
62
|
return;
|
|
55
63
|
}
|
|
56
64
|
train.state = 回弹;
|
|
@@ -70,6 +78,9 @@ function inertia(gun) {
|
|
|
70
78
|
};
|
|
71
79
|
train.smooth = function (d, r) {
|
|
72
80
|
_cancel();
|
|
81
|
+
if (isFunction(d) && !isFinite(r)) {
|
|
82
|
+
r = 1;
|
|
83
|
+
}
|
|
73
84
|
decrease = d;
|
|
74
85
|
rate = r;
|
|
75
86
|
if (train.state === 移动) {
|
package/coms/basic/combgen.js
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
function* combgen() {
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
total *= a.length;
|
|
5
|
-
return a;
|
|
6
|
-
});
|
|
7
|
-
var temp = total;
|
|
8
|
-
var ratioList = argsList.map(a => temp = temp / a.length);
|
|
2
|
+
var [f, args] = Comb.args(arguments);
|
|
3
|
+
var arr = new Comb(f, args);
|
|
9
4
|
var i = 0;
|
|
10
|
-
for (var cx = 0, dx =
|
|
11
|
-
var
|
|
12
|
-
var res = yield argsList.map(function (a, cx) {
|
|
13
|
-
var index = temp / ratioList[cx] | 0;
|
|
14
|
-
temp = temp - index * ratioList[cx];
|
|
15
|
-
return a[index];
|
|
16
|
-
});
|
|
5
|
+
for (var cx = 0, dx = arr.length; cx < dx; cx++) {
|
|
6
|
+
var res = yield arr.get(cx);
|
|
17
7
|
if (res === false) {
|
|
18
8
|
i++;
|
|
19
|
-
if (i >
|
|
20
|
-
var tx =
|
|
9
|
+
if (i > args.length) break;
|
|
10
|
+
var tx = args[args.length - i].length;
|
|
21
11
|
cx += tx - cx % tx - 1;
|
|
22
12
|
}
|
|
23
13
|
else {
|
package/coms/basic/combine.js
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
|
+
var Comb = require("./Comb");
|
|
1
2
|
function combine() {
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var temp = total;
|
|
9
|
-
var ratioList = argsList.map(a => temp = temp / a.length);
|
|
10
|
-
var dist = new Array(total);
|
|
11
|
-
for (var cx = 0, dx = total; cx < dx; cx++) {
|
|
12
|
-
var temp = cx;
|
|
13
|
-
dist[cx] = argsList.map(function (a, cx) {
|
|
14
|
-
var index = temp / ratioList[cx] | 0;
|
|
15
|
-
temp = temp - index * ratioList[cx];
|
|
16
|
-
return a[index];
|
|
17
|
-
});
|
|
3
|
+
var [f, args] = Comb.args(arguments);
|
|
4
|
+
var arr = new Comb(f, args);
|
|
5
|
+
var dist = new Array(arr.length);
|
|
6
|
+
for (var cx = 0, dx = arr.length; cx < dx; cx++) {
|
|
7
|
+
dist[cx] = arr.get(cx);
|
|
18
8
|
}
|
|
19
9
|
return dist;
|
|
20
10
|
}
|
|
@@ -443,7 +443,8 @@ function addhook() {
|
|
|
443
443
|
}
|
|
444
444
|
if (!mousedownEvent) return;
|
|
445
445
|
var target = targetElement || mousedownEvent.currentTarget;
|
|
446
|
-
hooka.call(targetElement, function (
|
|
446
|
+
hooka.call(targetElement, function () {
|
|
447
|
+
var target = drag.shadow;
|
|
447
448
|
var res = Array.prototype.filter.call(allowdrops || (boxfinder ? boxfinder(target) : document.querySelectorAll("[allowdrop]")), function (child) {
|
|
448
449
|
return target && overlap(child, target);
|
|
449
450
|
}).filter(e => {
|
|
@@ -67,8 +67,10 @@ var getGenerator = function (container, tagName = 'item') {
|
|
|
67
67
|
*/
|
|
68
68
|
return container.$generator = function (index, com, element) {
|
|
69
69
|
if (com === undefined) {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
var src = container.src;
|
|
71
|
+
if (!src || index >= src.length) return;
|
|
72
|
+
if (isFunction(src.get)) com = src.get(index);
|
|
73
|
+
else com = src[index];
|
|
72
74
|
}
|
|
73
75
|
if (com === undefined) return;
|
|
74
76
|
if (isNode(element));
|
package/coms/zimoli/list.js
CHANGED
|
@@ -51,16 +51,18 @@ function ylist(container, generator, $Y) {
|
|
|
51
51
|
}
|
|
52
52
|
return null;
|
|
53
53
|
};
|
|
54
|
+
var isSticky = child => isNode(child) && /^(sticky|fixed|absolute)$/.test(getComputedStyle(child).position);
|
|
54
55
|
var getFirstVisibleElement = function (deltaY) {
|
|
55
56
|
var children = list.childNodes;
|
|
56
57
|
var { scrollTop } = list;
|
|
57
|
-
|
|
58
|
+
var paddingTop = parseFloat(getComputedStyle(list).paddingTop);
|
|
59
|
+
deltaY = paddingTop + (deltaY || 0);
|
|
58
60
|
if (deltaY) scrollTop += deltaY;
|
|
59
61
|
for (var cx = 0, dx = children.length; cx < dx; cx++) {
|
|
60
62
|
var child = children[cx];
|
|
61
|
-
if (!isFinite(child.index) || child.index === null) continue;
|
|
63
|
+
if (!isFinite(child.index) || child.index === null || isSticky(child)) continue;
|
|
62
64
|
var c = getNodeTarget(child);
|
|
63
|
-
if (c.offsetTop + c.offsetHeight
|
|
65
|
+
if (c.offsetTop + c.offsetHeight >= scrollTop + 1) return deltaY === 0 ? child : c;
|
|
64
66
|
}
|
|
65
67
|
return null;
|
|
66
68
|
};
|
|
@@ -101,13 +103,14 @@ function ylist(container, generator, $Y) {
|
|
|
101
103
|
var getLastVisibleElement = function (deltaY) {
|
|
102
104
|
var { scrollTop } = list;
|
|
103
105
|
deltaY = +deltaY;
|
|
106
|
+
var paddingBottom = parseFloat(getComputedStyle(list).paddingBottom);
|
|
104
107
|
if (deltaY) scrollTop += deltaY;
|
|
105
108
|
var children = list.children;
|
|
106
109
|
for (var cx = children.length - 1; cx >= 0; cx--) {
|
|
107
110
|
var child = children[cx];
|
|
108
|
-
if (!isFinite(child.index)) continue;
|
|
111
|
+
if (!isFinite(child.index) || isSticky(child)) continue;
|
|
109
112
|
var c = getNodeTarget(child);
|
|
110
|
-
if (c.offsetTop
|
|
113
|
+
if (c.offsetTop + 1 <= scrollTop + list.clientHeight - paddingBottom) {
|
|
111
114
|
return deltaY === 0 ? child : c;
|
|
112
115
|
}
|
|
113
116
|
}
|
|
@@ -129,7 +132,7 @@ function ylist(container, generator, $Y) {
|
|
|
129
132
|
};
|
|
130
133
|
var createItem = function (index) {
|
|
131
134
|
var item = generator(index);
|
|
132
|
-
if (item) {
|
|
135
|
+
if (isNode(item)) {
|
|
133
136
|
item.index = index;
|
|
134
137
|
}
|
|
135
138
|
return item;
|
|
@@ -137,6 +140,7 @@ function ylist(container, generator, $Y) {
|
|
|
137
140
|
//设置当前下标
|
|
138
141
|
var scrollTo = function (itemIndex) {
|
|
139
142
|
if (isNaN(itemIndex)) return;
|
|
143
|
+
lastY = NaN;
|
|
140
144
|
itemIndex = +itemIndex;
|
|
141
145
|
__animated = false;
|
|
142
146
|
if (!list.offsetHeight && !list.offsetWidth && !isMounted(list)) {
|
|
@@ -334,8 +338,8 @@ function ylist(container, generator, $Y) {
|
|
|
334
338
|
item = getNodeTarget(item);
|
|
335
339
|
scrollTop += flag_element.offsetTop - offsetTop;
|
|
336
340
|
offsetTop = flag_element.offsetTop;
|
|
337
|
-
first_element = item;
|
|
338
341
|
}
|
|
342
|
+
first_element = item;
|
|
339
343
|
}
|
|
340
344
|
//滚动到相应位置
|
|
341
345
|
if (scrollTop < 0) scrollTop = 0;
|
|
@@ -377,15 +381,25 @@ function ylist(container, generator, $Y) {
|
|
|
377
381
|
});
|
|
378
382
|
list.getLastVisibleElement = getLastVisibleElement;
|
|
379
383
|
list.getFirstVisibleElement = getFirstVisibleElement;
|
|
384
|
+
var lastY = NaN;
|
|
385
|
+
//
|
|
386
|
+
// 最大距离 S,最大初始速度 V = a * t = 1,求加速 a
|
|
387
|
+
// S = 0.5 * a * t * t = 0.5 * V * t;
|
|
388
|
+
// => t = S * 2 / V = S * 2, a = V / t = 1 / (S * 2);
|
|
389
|
+
//
|
|
390
|
+
// 加速度a = 1 / (S * 2),对任意s,有t = sqrt(2 * s / a) = sqrt(2 * s * S * 2) = 2 * sqrt(s * S);
|
|
391
|
+
// 对应速度 v = a * t = 1 / (S * 2) * 2 * sqrt(s * S) = sqrt(s * S) / S;
|
|
392
|
+
// 临近零点的距离 s0 = a / 2 = 1 / (S * 4);
|
|
380
393
|
list.$stopY = function (t, spd) {
|
|
381
394
|
var firstElement = getFirstVisibleElement();
|
|
382
395
|
var lastElement = getLastVisibleElement();
|
|
383
396
|
if (!firstElement || !lastElement || !list.clientHeight) return false;
|
|
384
|
-
|
|
397
|
+
if (isNaN(lastY)) return false;
|
|
398
|
+
var paddingTop = parseFloat(getComputedStyle(list).paddingTop);
|
|
385
399
|
var paddingBottom = parseFloat(getComputedStyle(list).paddingBottom);
|
|
386
400
|
var scrolled_t = (list.scrollTop - firstElement.offsetTop + paddingTop) / firstElement.offsetHeight;
|
|
387
401
|
if (scrolled_t > 1) scrolled_t -= scrolled_t | 0;
|
|
388
|
-
var last_y =
|
|
402
|
+
var last_y = lastY;
|
|
389
403
|
if (spd[0] > 0) {
|
|
390
404
|
var target_ty = last_y + (1 - scrolled_t) * firstElement.offsetHeight;
|
|
391
405
|
} else {
|
|
@@ -398,17 +412,16 @@ function ylist(container, generator, $Y) {
|
|
|
398
412
|
} else {
|
|
399
413
|
var target_by = last_y - scrolled_b * lastElement.offsetHeight;
|
|
400
414
|
}
|
|
415
|
+
var S = calcPixel(30);
|
|
401
416
|
var target_y = Math.abs(target_ty - last_y) > Math.abs(target_by - last_y) ? target_by : target_ty;
|
|
402
|
-
var delta = Math.min(
|
|
417
|
+
var delta = Math.min(S, list.clientHeight >> 2);
|
|
403
418
|
var absy = Math.abs(target_y - last_y), y;
|
|
404
419
|
if (absy >= delta) {
|
|
405
420
|
return false;
|
|
406
421
|
}
|
|
407
|
-
if (absy
|
|
422
|
+
if (absy < 1) y = target_y;
|
|
408
423
|
else {
|
|
409
|
-
var speed =
|
|
410
|
-
if (speed < 1) speed = 1;
|
|
411
|
-
if (absy < 3) speed = .5;
|
|
424
|
+
var speed = Math.sqrt(absy * S) / S;
|
|
412
425
|
y = last_y + (target_y > last_y ? speed : -speed);
|
|
413
426
|
}
|
|
414
427
|
list.$Top(y);
|
|
@@ -428,6 +441,7 @@ function ylist(container, generator, $Y) {
|
|
|
428
441
|
};
|
|
429
442
|
list.$Top = function (y) {
|
|
430
443
|
if (isFinite(y)) {
|
|
444
|
+
lastY = y;
|
|
431
445
|
var last_y = currentY();
|
|
432
446
|
if (y !== last_y) {
|
|
433
447
|
scrollBy(y - last_y);
|
|
@@ -625,7 +639,8 @@ function list() {
|
|
|
625
639
|
generator = getGeneratorFromArray(container);
|
|
626
640
|
bindSrc = container;
|
|
627
641
|
container = div();
|
|
628
|
-
}
|
|
642
|
+
}
|
|
643
|
+
else if (container && !generator) {
|
|
629
644
|
if (bindSrc) {
|
|
630
645
|
generator = getGenerator(container);
|
|
631
646
|
bindSrc = true;
|
|
@@ -656,7 +671,7 @@ function list() {
|
|
|
656
671
|
appendChild.wrapTarget(container);
|
|
657
672
|
var list = ($Y === "X" ? xlist : ylist)(container, generator, $Y);
|
|
658
673
|
if (!list.group) list.group = groupCount || 2;
|
|
659
|
-
if (bindSrc instanceof Array) {
|
|
674
|
+
if (bindSrc instanceof Array || isFunction(bindSrc?.next)) {
|
|
660
675
|
list.src = bindSrc;
|
|
661
676
|
container.go(container.index() || 0);
|
|
662
677
|
} else if (bindSrc === true) {
|
|
@@ -670,6 +685,10 @@ function list() {
|
|
|
670
685
|
if (c.nodeType === 1 && c.$comment && isFinite(c.$comment.index)) return true;
|
|
671
686
|
return false;
|
|
672
687
|
});
|
|
688
|
+
if (isFunction(src?.next)) {
|
|
689
|
+
remove(children);
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
673
692
|
if (src && old) children = Array.prototype.filter.call(children, c => src[c.index] !== old[c.index]);
|
|
674
693
|
remove(children);
|
|
675
694
|
};
|
package/coms/zimoli/list.less
CHANGED
package/coms/zimoli/model.js
CHANGED
|
@@ -303,11 +303,11 @@ var getOptionsFrom = function () {
|
|
|
303
303
|
};
|
|
304
304
|
function setModel(ipt) {
|
|
305
305
|
var elem = this;
|
|
306
|
-
if (isHandled(ipt)
|
|
306
|
+
if (isHandled(ipt)) {
|
|
307
307
|
if (isNode(ipt)) {
|
|
308
308
|
var model = new Model(getScopeValue, setScopeValue, ipt);
|
|
309
309
|
model.hook(elem, elem.field.option_to ? copyOptionData : true);
|
|
310
|
-
appendChild(elem, ipt);
|
|
310
|
+
if (elem !== ipt) appendChild(elem, ipt);
|
|
311
311
|
}
|
|
312
312
|
else {
|
|
313
313
|
elem.innerText = ipt;
|
package/coms/zimoli/render.js
CHANGED
|
@@ -62,7 +62,6 @@ var addRenderElement = function () {
|
|
|
62
62
|
if (!isNode(element)) return;
|
|
63
63
|
if (element.$renderid !== 9) {
|
|
64
64
|
// 只渲染一次
|
|
65
|
-
if (element.$renderid < 10 && element.$renderid > 0) element.$renderid = ++renderidOffset;
|
|
66
65
|
renderElements[element.$renderid] = element;
|
|
67
66
|
}
|
|
68
67
|
buildFirst(element);
|
|
@@ -170,18 +169,10 @@ var createComment = function (renders, type, expression) {
|
|
|
170
169
|
};
|
|
171
170
|
|
|
172
171
|
var initialComment = function (comment) {
|
|
173
|
-
if (
|
|
174
|
-
comment.$renderid = ++renderidOffset;
|
|
175
|
-
onmounted(comment, addRenderElement);
|
|
176
|
-
onremove(comment, removeRenderElement);
|
|
177
|
-
if (isMounted(comment) || eagermount) rebuild(comment);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
172
|
+
if (comment.$struct.once) {
|
|
180
173
|
comment.$renderid = 9;
|
|
181
|
-
rebuild(comment);
|
|
182
|
-
if (comment.with) comment.with = null;
|
|
183
|
-
remove(comment);
|
|
184
174
|
}
|
|
175
|
+
renderlock.push(comment);
|
|
185
176
|
};
|
|
186
177
|
|
|
187
178
|
class Repeater {
|
|
@@ -316,8 +307,7 @@ var createRepeat = function (search, id = 0) {
|
|
|
316
307
|
}
|
|
317
308
|
}
|
|
318
309
|
}
|
|
319
|
-
var clone = element.cloneNode();
|
|
320
|
-
clone.innerHTML = element.innerHTML;
|
|
310
|
+
var clone = element.cloneNode(true);
|
|
321
311
|
clone.$renderid = id;
|
|
322
312
|
clone.$repeat = clone.$scope = $scope;
|
|
323
313
|
clone.$parentScopes = $parentScopes;
|
|
@@ -347,7 +337,7 @@ var createRepeat = function (search, id = 0) {
|
|
|
347
337
|
initialComment(comment);
|
|
348
338
|
return comment;
|
|
349
339
|
};
|
|
350
|
-
var
|
|
340
|
+
var initIfs = function (ifs) {
|
|
351
341
|
for (var s of ifs) {
|
|
352
342
|
initialComment(s[0]);
|
|
353
343
|
}
|
|
@@ -505,7 +495,7 @@ var structures = {
|
|
|
505
495
|
if (cx < 0) {
|
|
506
496
|
throw new Error(i18n`else/elseif前缺少同级if!`);
|
|
507
497
|
}
|
|
508
|
-
|
|
498
|
+
if (cx + 1 < if_top.length) initIfs(if_top.splice(cx + 1, if_top.length - cx - 1));
|
|
509
499
|
var top = if_top[cx];
|
|
510
500
|
if (search) var getter = createGetter(this, search);
|
|
511
501
|
var comment = createComment.call(this, undefined, search ? 'elseif' : 'else', search);
|
|
@@ -812,7 +802,7 @@ var createEmiter = function (on) {
|
|
|
812
802
|
else {
|
|
813
803
|
onkey = on(key);
|
|
814
804
|
}
|
|
815
|
-
onkey(target, new Emitter(emit, getScopeList(
|
|
805
|
+
onkey(target, new Emitter(emit, getScopeList(this)));
|
|
816
806
|
};
|
|
817
807
|
};
|
|
818
808
|
var emiters = {
|
|
@@ -888,12 +878,28 @@ function renderRest(element, struct, replacer = element) {
|
|
|
888
878
|
if (!isElement(replacer)) replacer = element;
|
|
889
879
|
struct.ons.forEach(([on, key, value]) => on.call(element, replacer, key, value));
|
|
890
880
|
}
|
|
891
|
-
|
|
881
|
+
function renderArray(children, scope, parentScopes, once) {
|
|
882
|
+
if (!children) return;
|
|
883
|
+
if (children.length) {
|
|
884
|
+
var if_top_length = if_top.length;
|
|
885
|
+
for (var cx = 0, dx = children.length; cx < dx; cx++) {
|
|
886
|
+
children[cx] = renderElement(children[cx], scope, parentScopes, once);
|
|
887
|
+
}
|
|
888
|
+
if (if_top_length < if_top.length) {
|
|
889
|
+
initIfs(if_top.splice(if_top_length, if_top.length - if_top_length));
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
return children;
|
|
893
|
+
}
|
|
894
|
+
function getChildren(element) {
|
|
895
|
+
var children = element.children;
|
|
896
|
+
if (!children || !children.length) return;
|
|
897
|
+
var children = Array.prototype.filter.call(children, a => !a.$renderid);
|
|
898
|
+
return children
|
|
899
|
+
}
|
|
892
900
|
function renderElement(element, scope = element.$scope, parentScopes = element.$parentScopes, once) {
|
|
893
901
|
if (isArrayLike(element)) {
|
|
894
|
-
return Array.apply(null, element)
|
|
895
|
-
return renderElement(element, scope, parentScopes, once);
|
|
896
|
-
});
|
|
902
|
+
return renderArray(Array.apply(null, element), scope, parentScopes, once);
|
|
897
903
|
}
|
|
898
904
|
if (!isElement(element)) {
|
|
899
905
|
return element;
|
|
@@ -919,7 +925,7 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
919
925
|
element.$scope = scope;
|
|
920
926
|
if (element.$renderid <= -1) element = renderStructure(element);
|
|
921
927
|
if (!element) return;
|
|
922
|
-
if (
|
|
928
|
+
if (element.$renderid < 0 || element.nodeType !== 1) {
|
|
923
929
|
return element;
|
|
924
930
|
}
|
|
925
931
|
var isFirstRender = !element.$renderid;
|
|
@@ -954,7 +960,7 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
954
960
|
if (!replacer.$scope) replacer.$scope = scope;
|
|
955
961
|
if (!replacer.$parentScopes) replacer.$parentScopes = parentScopes;
|
|
956
962
|
createStructure(replacer);
|
|
957
|
-
|
|
963
|
+
renderArray(getChildren(replacer), replacer.$scope, replacer.$parentScopes, once);
|
|
958
964
|
renderRest(replacer, replacer.$struct);
|
|
959
965
|
}
|
|
960
966
|
copyAttribute(replacer, copys);
|
|
@@ -968,9 +974,7 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
|
|
|
968
974
|
}
|
|
969
975
|
}
|
|
970
976
|
}
|
|
971
|
-
if (!replacer || element === replacer)
|
|
972
|
-
if (element.children && element.children.length) renderElement(element.children, scope, parentScopes, once);
|
|
973
|
-
}
|
|
977
|
+
if (!replacer || element === replacer) renderArray(getChildren(element), scope, parentScopes, once);
|
|
974
978
|
if (isFirstRender) {
|
|
975
979
|
renderRest(element, $struct, replacer);
|
|
976
980
|
if (isNode(replacer) && replacer !== element) {
|
|
@@ -1229,10 +1233,10 @@ function renderUnlock() {
|
|
|
1229
1233
|
renderlock = null;
|
|
1230
1234
|
locked.forEach(element => {
|
|
1231
1235
|
if (element.$renderid !== 9) {
|
|
1236
|
+
element.$renderid = ++renderidOffset;
|
|
1232
1237
|
on("append")(element, addRenderElement);
|
|
1233
1238
|
onremove(element, removeRenderElement);
|
|
1234
|
-
if (isMounted(element));
|
|
1235
|
-
else if (element.$renderid > 1) addRenderElement.call(element);
|
|
1239
|
+
if (isMounted(element) || element.nodeType === 8);
|
|
1236
1240
|
else if (eagermount) buildFirst(element);
|
|
1237
1241
|
}
|
|
1238
1242
|
else {
|
|
@@ -1257,8 +1261,8 @@ function render(element, scope, parentScopes, lazy = true) {
|
|
|
1257
1261
|
var renderonce = lazy === 0;
|
|
1258
1262
|
if (haslock) eagermount = !+lazy;
|
|
1259
1263
|
var e = renderElement(element, scope, parentScopes, renderonce);
|
|
1264
|
+
if (if_top_length < if_top.length) initIfs(if_top.splice(if_top_length, if_top.length - if_top_length));
|
|
1260
1265
|
if (haslock) renderUnlock(element);
|
|
1261
|
-
if (if_top_length < if_top.length) initIf(if_top.splice(if_top_length, if_top.length - if_top_length));
|
|
1262
1266
|
if (haslock) callDigest();
|
|
1263
1267
|
return e;
|
|
1264
1268
|
}
|
package/coms/zimoli/tree.js
CHANGED
|
@@ -270,9 +270,9 @@ function tree() {
|
|
|
270
270
|
var stickys = [];
|
|
271
271
|
var setSticky = function () {
|
|
272
272
|
var p = stickys[stickys.length - 1];
|
|
273
|
-
var f = banner.getFirstVisibleElement(stickys.top
|
|
273
|
+
var f = banner.getFirstVisibleElement(stickys.top);
|
|
274
274
|
if (!f) return;
|
|
275
|
-
var limitHeight = f.offsetTop - banner.scrollTop;
|
|
275
|
+
var limitHeight = f.offsetTop - banner.scrollTop - parseFloat(getComputedStyle(banner).paddingTop);
|
|
276
276
|
var c = dom[f.$index];
|
|
277
277
|
var useLimit = false;
|
|
278
278
|
if (p) {
|
package/coms/zimoli/vbox.js
CHANGED
|
@@ -30,6 +30,7 @@ function ybox(generator) {
|
|
|
30
30
|
if (_box.$Height !== _box_Height) _box.$Height = _box_Height;
|
|
31
31
|
if (_box.$height !== _box_height) _box.$height = _box_height;
|
|
32
32
|
if (_box.$Top !== _box_Top) _box.$Top = _box_Top;
|
|
33
|
+
_box.parked = true;
|
|
33
34
|
_box.$scrollY = function (deltay, useIncrease = _box.useIncrease !== false) {
|
|
34
35
|
var _Top = _box.$Top();
|
|
35
36
|
var top = _Top + deltay;
|
|
@@ -89,14 +90,17 @@ function ybox(generator) {
|
|
|
89
90
|
remove(increaser);
|
|
90
91
|
return 0;
|
|
91
92
|
};
|
|
93
|
+
scrollY.park = function () {
|
|
94
|
+
_box.parked = true;
|
|
95
|
+
};
|
|
92
96
|
var stop = _box.$stopY || _box.stopY;
|
|
93
97
|
var stop2 = lazy(function () {
|
|
94
|
-
scrollY.smooth(stop
|
|
98
|
+
scrollY.smooth(stop);
|
|
95
99
|
}, 40);
|
|
96
100
|
var decrease = function (t) {
|
|
97
101
|
var res = _decrease(increaser_t, t) + _decrease(increaser_b, t);
|
|
98
102
|
if (!res) {
|
|
99
|
-
scrollY.smooth(stop
|
|
103
|
+
scrollY.smooth(stop);
|
|
100
104
|
}
|
|
101
105
|
return true;
|
|
102
106
|
};
|
|
@@ -170,6 +174,7 @@ function ybox(generator) {
|
|
|
170
174
|
bindtouch(_box, {
|
|
171
175
|
start() {
|
|
172
176
|
scrollY.reset();
|
|
177
|
+
_box.parked = false;
|
|
173
178
|
},
|
|
174
179
|
move(scrolled) {
|
|
175
180
|
var y = -_box.$Top();
|
package/coms/zimoli/view.less
CHANGED
|
@@ -7,7 +7,7 @@ predefs["module.exports"] = true;
|
|
|
7
7
|
predefs.Promise = true;
|
|
8
8
|
[Boolean, Number, String, Function, Object, Array, Date, RegExp, Error].forEach(p => predefs[p.name] = true);
|
|
9
9
|
var wrapLabel = function (content, typeName) {
|
|
10
|
-
return `<${
|
|
10
|
+
return `<${typeName}>${content}</${typeName}>`;
|
|
11
11
|
};
|
|
12
12
|
var amp = a => `&#${a.charCodeAt()};`;
|
|
13
13
|
var encodeAmp = function (a) {
|
|
@@ -68,9 +68,11 @@ var codecolor = function (c, encode) {
|
|
|
68
68
|
}
|
|
69
69
|
else endi++;
|
|
70
70
|
var [name] = keys;
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
if (name && endi > 0) {
|
|
72
|
+
if (!o.isprop && o.text !== name && isConstValue(name)) name = wrap(name, "strap");
|
|
73
|
+
else name = wrap(name, label);
|
|
74
|
+
keys[0] = name;
|
|
75
|
+
}
|
|
74
76
|
for (var cx = 1, dx = endi; cx < dx; cx++) {
|
|
75
77
|
var k = keys[cx];
|
|
76
78
|
keys[cx] = /^[\?]/.test(k) || !k ? k : wrap(k, 'express');
|
|
@@ -92,6 +94,10 @@ var codecolor = function (c, encode) {
|
|
|
92
94
|
});
|
|
93
95
|
return t;
|
|
94
96
|
};
|
|
97
|
+
var wrapcode = encode ? function (t, l) {
|
|
98
|
+
t = encode(t);
|
|
99
|
+
return wrap(t, l);
|
|
100
|
+
} : wrap;
|
|
95
101
|
c.colored = true;
|
|
96
102
|
var setcolor = function (o) {
|
|
97
103
|
if (o.colored) return;
|
|
@@ -129,19 +135,19 @@ var codecolor = function (c, encode) {
|
|
|
129
135
|
break;
|
|
130
136
|
case ELEMENT:
|
|
131
137
|
if (o.attributes) o.attributes.forEach(setcolor);
|
|
132
|
-
if (o.tag_entry) o.tag_entry =
|
|
133
|
-
if (o.tag_leave) o.tag_leave =
|
|
134
|
-
if (o.entry) o.entry =
|
|
135
|
-
if (o.leave) o.leave =
|
|
136
|
-
o.tag =
|
|
138
|
+
if (o.tag_entry) o.tag_entry = wrapcode(o.tag_entry, 'stamp');
|
|
139
|
+
if (o.tag_leave) o.tag_leave = wrapcode(o.tag_leave, 'stamp');
|
|
140
|
+
if (o.entry) o.entry = wrapcode(o.entry, 'stamp');
|
|
141
|
+
if (o.leave) o.leave = wrapcode(o.leave, 'stamp');
|
|
142
|
+
o.tag = wrapcode(o.tag, 'label');
|
|
137
143
|
o.forEach(setcolor);
|
|
138
144
|
break;
|
|
139
145
|
case SCOPED:
|
|
140
146
|
deep++;
|
|
141
147
|
o.forEach(setcolor);
|
|
142
148
|
deep--;
|
|
143
|
-
o.entry =
|
|
144
|
-
o.leave =
|
|
149
|
+
o.entry = wrapcode(o.entry, 'deep' + deep);
|
|
150
|
+
o.leave = wrapcode(o.leave, 'deep' + deep);
|
|
145
151
|
break;
|
|
146
152
|
case VALUE:
|
|
147
153
|
if (o.isdigit) o.text = wrap(o.text, 'digit');
|
|
@@ -163,7 +169,7 @@ var codecolor = function (c, encode) {
|
|
|
163
169
|
else o.text = wrap(o.text, 'strap');
|
|
164
170
|
break;
|
|
165
171
|
case STAMP:
|
|
166
|
-
if (/^(=>)$/.test(o.text) || o.text === "*" && o.prev && o.prev.type === STRAP) o.text =
|
|
172
|
+
if (/^(=>)$/.test(o.text) || o.text === "*" && o.prev && o.prev.type === STRAP) o.text = wrapcode(o.text, 'strap');
|
|
167
173
|
break;
|
|
168
174
|
case COMMENT:
|
|
169
175
|
o.text = wraptext(o.text, 'comment');
|