efront 3.25.7 → 3.25.11

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.
Files changed (41) hide show
  1. package/apps/_index.html +1 -1
  2. package/coms/basic/Item.js +13 -3
  3. package/coms/basic/Speed.js +36 -17
  4. package/coms/basic/Tree.js +4 -4
  5. package/coms/{zimoli → basic}/cancelAnimationFrame.js +1 -0
  6. package/coms/basic/lazy.js +29 -12
  7. package/coms/basic/loader.js +12 -9
  8. package/coms/basic/mark.js +1 -1
  9. package/coms/basic/mark_test.js +7 -0
  10. package/coms/basic/renderExpress.js +3 -3
  11. package/coms/frame/route.js +12 -3
  12. package/coms/kugou/playList.less +6 -0
  13. package/coms/zimoli/bindAccesskey.js +13 -5
  14. package/coms/zimoli/button.js +2 -1
  15. package/coms/zimoli/getGenerator.js +24 -8
  16. package/coms/zimoli/getName.js +7 -5
  17. package/coms/zimoli/hexagon.js +33 -0
  18. package/coms/zimoli/innerHeight.js +2 -1
  19. package/coms/zimoli/innerWidth.js +2 -1
  20. package/coms/zimoli/list.js +146 -17
  21. package/coms/zimoli/menu.js +7 -3
  22. package/coms/zimoli/menuItem.html +8 -3
  23. package/coms/zimoli/menuItem.js +2 -2
  24. package/coms/zimoli/menuItem.less +3 -2
  25. package/coms/zimoli/menuList.js +188 -196
  26. package/coms/zimoli/menuList.less +1 -1
  27. package/coms/zimoli/moveupon.js +1 -0
  28. package/coms/zimoli/on.js +54 -16
  29. package/coms/zimoli/onmousewheel.js +1 -1
  30. package/coms/zimoli/popup.js +17 -22
  31. package/coms/zimoli/render.js +7 -5
  32. package/coms/zimoli/resize.js +1 -0
  33. package/coms/zimoli/slider.js +23 -9
  34. package/coms/zimoli/slider_test.js +1 -1
  35. package/coms/zimoli/table.js +7 -1
  36. package/coms/zimoli/touchList.js +22 -20
  37. package/coms/zimoli/vbox.js +11 -8
  38. package/docs/main.js +3 -0
  39. package/package.json +2 -2
  40. package/public/efront.js +1 -1
  41. package/coms/zimoli/menuList.html +0 -6
@@ -2,9 +2,12 @@
2
2
  function ylist(container, generator, $Y) {
3
3
  const cache_height = 2000;
4
4
  var restHeight = cache_height;
5
+ /**
6
+ * @type {HTMLElement}
7
+ */
5
8
  var list = container || div();
6
9
  list.autoFix = true;
7
- var saved_itemIndex;
10
+ var saved_itemIndex = 0;
8
11
  addClass(list, 'list-' + $Y.toLowerCase());
9
12
  if (!list.renders) {
10
13
  list.renders = [];
@@ -15,7 +18,11 @@ function ylist(container, generator, $Y) {
15
18
  if (a !== void 0) scrollTo(a);
16
19
  });
17
20
  var getNodeTarget = function (node) {
18
- if (node.nodeType === 8 && node.template) return node.template;
21
+ if (node.nodeType === 8 && node.$template) {
22
+ var t = node.$template;
23
+ if (!isFinite(t.index)) t.index = node.index;
24
+ return node.$template;
25
+ }
19
26
  return node;
20
27
  };
21
28
  //取底部元素
@@ -109,7 +116,9 @@ function ylist(container, generator, $Y) {
109
116
  for (var cx = 0, dx = children.length; cx < dx; cx++) {
110
117
  var child = children[cx];
111
118
  if (isFinite(child.index) && child.index !== null) {
112
- map[child.index] = child;
119
+ if (!map[child.index] || child.$template === map[child.index]) {
120
+ map[child.index] = child;
121
+ }
113
122
  }
114
123
  }
115
124
  return map;
@@ -203,10 +212,12 @@ function ylist(container, generator, $Y) {
203
212
  return y;
204
213
  }, false);
205
214
  var rebuild = function () {
206
- if (!/^(?:auto|scroll)$/i.test(getComputedStyle(list).overflowY)) return;
207
215
  runbuild();
208
216
  };
209
- on("scroll")(list, rebuild);
217
+ oncemount(list, function () {
218
+ if (!/^(?:auto|scroll)$/i.test(getComputedStyle(list).overflowY)) return;
219
+ on("scroll")(list, rebuild);
220
+ });
210
221
  var topinsert = document.createElement('ylist-insert');
211
222
  list.insertBefore(topinsert, list.firstChild);
212
223
  //计算当前高度
@@ -228,17 +239,17 @@ function ylist(container, generator, $Y) {
228
239
  return bottom_element ? bottom_element.nextSibling : null;
229
240
  };
230
241
  var getOffsetHeight = function (element) {
242
+ element = getNodeTarget(element);
231
243
  var temp = element;
232
244
  do {
233
245
  var next = getNextSibling(temp);
234
246
  if (!next) return element.offsetHeight;
235
- temp = next;
247
+ temp = getNodeTarget(next);
236
248
  } while (next.offsetTop === element.offsetTop);
237
249
  return next.offsetTop - element.offsetTop;
238
250
  };
239
251
  var patchBottom = function (deltaY = 0) {
240
252
  var cache_height = list.offsetHeight;
241
-
242
253
  var childrenMap = getChildrenMap();
243
254
  var last_element = getLastElement(1);
244
255
  if (!last_element || !last_element.offsetHeight) return;
@@ -271,7 +282,7 @@ function ylist(container, generator, $Y) {
271
282
  var collection = [];
272
283
  for (var k in childrenMap) {
273
284
  let item = childrenMap[k];
274
- if (item.offsetTop + getOffsetHeight(item) + cache_height < scrollTop) {
285
+ if (getNodeTarget(item).offsetTop + getOffsetHeight(item) + cache_height < scrollTop) {
275
286
  collection.push(item);
276
287
  }
277
288
  }
@@ -283,7 +294,7 @@ function ylist(container, generator, $Y) {
283
294
  item = collection.pop();
284
295
  }
285
296
  var item = collection[collection.length - 1];
286
- if (item) scrollTop -= item.offsetTop + getOffsetHeight(item) - collection[0].offsetTop;
297
+ if (item) scrollTop -= getNodeTarget(item).offsetTop + getOffsetHeight(item) - getNodeTarget(collection[0]).offsetTop;
287
298
  if (paddingCount > 0 && paddingMax > 0 && paddingCount < paddingMax) {
288
299
  let item = collection[collection.length - 1];
289
300
  while (paddingCount > 0) {
@@ -337,6 +348,7 @@ function ylist(container, generator, $Y) {
337
348
  var { clientHeight } = list;
338
349
  while (last_element && last_element.offsetTop > clientHeight + scrollTop + cache_height) {
339
350
  remove(last_element);
351
+ remove(last_element.$comment);
340
352
  last_element = getLastElement(1);
341
353
  }
342
354
  return scrollTop - list.scrollTop;
@@ -364,8 +376,11 @@ function ylist(container, generator, $Y) {
364
376
  }
365
377
  }
366
378
  };
379
+ bind('resize')(list, function () {
380
+ patchBottom(0);
381
+ });
367
382
  list.getLastVisibleElement = getLastVisibleElement;
368
- list.$stopY = function (count, spd) {
383
+ list.$stopY = function (t, spd) {
369
384
  var firstElement = getFirstVisibleElement();
370
385
  var lastElement = getLastVisibleElement();
371
386
  if (!firstElement || !lastElement || !list.clientHeight) return false;
@@ -387,16 +402,16 @@ function ylist(container, generator, $Y) {
387
402
  var target_by = last_y - scrolled_b * lastElement.offsetHeight;
388
403
  }
389
404
  var target_y = Math.abs(target_ty - last_y) > Math.abs(target_by - last_y) ? target_by : target_ty;
390
- var delta = Math.min(calcPixel(60), list.clientHeight >> 2);
391
- var deltay = Math.abs(target_y - last_y), y;
392
- if (deltay >= delta) {
405
+ var delta = Math.min(calcPixel(30), list.clientHeight >> 2);
406
+ var absy = Math.abs(target_y - last_y), y;
407
+ if (absy >= delta) {
393
408
  return false;
394
409
  }
395
- if (deltay < 2) y = target_y;
410
+ if (absy <= 1) y = target_y;
396
411
  else {
397
412
  var speed = Math.abs(spd.read()[0]);
398
413
  if (speed < 1) speed = 1;
399
- if (deltay < 3) speed = .5;
414
+ if (absy < 3) speed = .5;
400
415
  y = last_y + (target_y > last_y ? speed : -speed);
401
416
  }
402
417
  list.$Top(y);
@@ -410,7 +425,8 @@ function ylist(container, generator, $Y) {
410
425
  list.$Height = function () {
411
426
  var elem = getLastElement(2);
412
427
  var listRestHeight = elem ? elem.offsetHeight + elem.offsetTop - list.scrollTop : list.clientHeight;
413
- return currentY() + listRestHeight + restHeight;
428
+ var paddingHeight = elem ? 0 : restHeight;
429
+ return currentY() + listRestHeight + paddingHeight;
414
430
  };
415
431
  list.$Top = function (y) {
416
432
  if (isFinite(y)) {
@@ -442,13 +458,126 @@ function ylist(container, generator, $Y) {
442
458
  list.patchBottom = patchBottom;
443
459
  list.patchTop = patchTop;
444
460
  list.scrollIfNotCover = scrollIfNotCover;
461
+ list.getLastElement = getLastElement;
445
462
  vbox(list, $Y);
446
463
  on("remove")(list, function () {
447
464
  saved_itemIndex = list.index();
448
465
  });
449
466
  onmounted(list, function () {
450
467
  if (isFinite(saved_itemIndex)) list.go(saved_itemIndex);
451
- })
468
+ });
469
+ /**
470
+ * @param {Element|null} focused
471
+ * @param {boolean} animate
472
+ */
473
+ list.setFocus = function (focused, animate) {
474
+ if (focused && (focused.hasAttribute("disabled") || focused.hasAttribute("line"))) return;
475
+ if (!focused) {
476
+ if (list.focused) {
477
+ removeClass(list.focused, 'focus');
478
+ list.focused = null;
479
+ }
480
+ return;
481
+ }
482
+ if (list.focused === focused) return;
483
+ if (list.focused) removeClass(list.focused, 'focus');
484
+ addClass(focused, "focus");
485
+ var scrollTop = list.scrollTop;
486
+ var firstElement = getFirstElement(1);
487
+ var sideheight = 0;
488
+ if (firstElement) {
489
+ sideheight += parseFloat(getComputedStyle(firstElement).paddingTop + firstElement.clientTop);
490
+ sideheight += (firstElement.offsetHeight - sideheight - sideheight) * .3;
491
+ sideheight += parseFloat(getComputedStyle(list).paddingTop);
492
+ }
493
+ if (focused.offsetTop + focused.offsetHeight + sideheight > list.scrollTop + list.clientHeight) {
494
+ scrollTop = focused.offsetTop + focused.offsetHeight + sideheight - list.clientHeight;
495
+ }
496
+ if (focused.offsetTop < list.scrollTop + sideheight) {
497
+ scrollTop = focused.offsetTop - sideheight;
498
+ }
499
+ if (scrollTop !== list.scrollTop) scrollBy(scrollTop - list.scrollTop, animate);
500
+ list.focused = focused;
501
+ };
502
+
503
+ /**
504
+ * @param {number|"up"|"down"|"home"|"end"|"pageup"|"pagedown"}delta
505
+ * @param {boolean} emit
506
+ */
507
+ list.moveFocus = function (delta, emit = true) {
508
+ var focused = list.focused;
509
+ var newIndex = 0, total = 0;
510
+ if (delta === 'up') delta = -1;
511
+ if (delta === 'down') delta = 1;
512
+ if (typeof delta === 'string') {
513
+ switch (delta.toLowerCase()) {
514
+ case "home":
515
+ newIndex = 0;
516
+ delta = 1;
517
+ break;
518
+ case "end":
519
+ var lastElement = getLastElement(1);
520
+ if (!lastElement) return;
521
+ newIndex = lastElement.index;
522
+ delta = -1;
523
+ break;
524
+ case "pageup":
525
+ var firstElement = getFirstVisibleElement();
526
+ if (!firstElement) return;
527
+ newIndex = firstElement.index;
528
+ list.scrollBy(-list.clientHeight + firstElement.offsetHeight);
529
+ var lastElement = getLastVisibleElement();
530
+ if (lastElement.index < newIndex) newIndex = lastElement.index;
531
+ delta = -1;
532
+ break;
533
+ case "pagedown":
534
+ var lastElement = getLastVisibleElement();
535
+ if (!lastElement) return;
536
+ newIndex = lastElement.index;
537
+ list.scrollBy(list.clientHeight - lastElement.offsetHeight);
538
+ var firstElement = getFirstVisibleElement();
539
+ if (firstElement.index > newIndex) newIndex = firstElement.index;
540
+ delta = 1;
541
+ break;
542
+ }
543
+ }
544
+ else if (!focused) {
545
+ var lastElement = getLastElement(1);
546
+ if (!lastElement) return;
547
+ total = lastElement.index + 1;
548
+ if (delta > 0) newIndex = 0;
549
+ else newIndex = total - 1;
550
+ }
551
+ else {
552
+ var newIndex = focused.index + delta;
553
+ var lastElement = getLastElement(1);
554
+ var total = lastElement.index + 1;
555
+ if (newIndex < 0) newIndex = total + newIndex;
556
+ if (newIndex > total - 1) newIndex = newIndex - total;
557
+ }
558
+ var savedIndex = newIndex;
559
+ var e = list.getIndexedElement(newIndex);
560
+ while (e && (e.hasAttribute("disabled") || e.hasAttribute("line"))) {
561
+ if (delta > 0) {
562
+ newIndex++;
563
+ if (newIndex >= total) {
564
+ if (!total) return;
565
+ newIndex = 0;
566
+ }
567
+ } else {
568
+ newIndex--;
569
+ if (newIndex < 0) {
570
+ if (!total) return;
571
+ newIndex = total - 1;
572
+ }
573
+ }
574
+ if (savedIndex === newIndex) return;
575
+ e = list.getIndexedElement(newIndex);
576
+ }
577
+ if (!e) list.setFocus(null);
578
+ else if (emit) list.setFocus(e, true), dispatch(list, 'focused');
579
+ else list.setFocus(e);
580
+ };
452
581
  return list;
453
582
  }
454
583
  var allArgumentsNames = arguments[arguments.length - 1];
@@ -89,13 +89,18 @@ var getTreeNodes = function (elem) {
89
89
  [].forEach.call(elem.children, run);
90
90
  return nodes;
91
91
  };
92
+ /**
93
+ * @param {any} item
94
+ * @param {Event} event
95
+ */
92
96
  var emitEvent = function (item, event) {
97
+ if (event.defaultPrevented) return;
93
98
  event.preventDefault(true);
94
99
  if (item.disabled) return;
95
100
  active(this, item, item, this.$src ? createItemTarget.call(this, item) : this);
96
101
  }
97
102
  function bindGlobalkey(elem, keymap, emit) {
98
- if (elem.keymap) {
103
+ if (elem.keyoff) {
99
104
  for (var off of elem.keyoff) {
100
105
  off();
101
106
  }
@@ -103,7 +108,7 @@ function bindGlobalkey(elem, keymap, emit) {
103
108
  if (!keymap) return;
104
109
  var keyoff = [];
105
110
  for (let k in keymap) {
106
- keyoff.push(bind("keydown." + k)(elem, emitEvent.bind(elem, keymap[k])));
111
+ keyoff.push(bind("keydown.only." + k)(elem, emitEvent.bind(elem, keymap[k])));
107
112
  }
108
113
  elem.keyoff = keyoff;
109
114
  }
@@ -190,7 +195,6 @@ function main(elem, mode) {
190
195
  active(elem, item, null, elem.$src ? createItemTarget.call(elem, item, target) : target);
191
196
  };
192
197
  if ("$src" in elem) {
193
- getGenerator(elem, 'menu-item');
194
198
  var src0 = [];
195
199
  menuList(elem, src0, emit, direction);
196
200
  care(elem, function (src) {
@@ -1,6 +1,11 @@
1
- <i ng-class="icon?" ng-if='useIcon||hasIcon'></i>
2
- <span ng-html="name?"></span>
3
- <template -if="hotkey?">
1
+ <template -if='useIcon||hasIcon||icon'>
2
+ <i -class="icon?" -style="{color:color?}"></i>
3
+ <template -if="name?">
4
+ &nbsp;&nbsp;
5
+ </template>
6
+ </template>
7
+ <span -html="name?" -style="{color:color?}"></span>
8
+ <template -if="hotkey?.length">
4
9
  &nbsp;&nbsp; <span ng-repeat="k of hotkey" class="hotkey" ng-html="k"></span>
5
10
  </template>
6
11
  <s></s>
@@ -17,6 +17,6 @@ function main(elem, scope, hasIcon) {
17
17
  }
18
18
  render(item.children, scope, hasIcon instanceof Array ? hasIcon : [{ useIcon: hasIcon, hasIcon }]);
19
19
  if (scope.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
20
- if (scope.hotkey) bindAccesskey(item, scope.hotkey);
21
20
  return item;
22
- }
21
+ }
22
+ main.template = menuItem;
@@ -1,6 +1,6 @@
1
1
  i {
2
2
  display: inline-block;
3
- width: 1em;
3
+ vertical-align: middle;
4
4
  }
5
5
 
6
6
  .hotkey {
@@ -17,7 +17,8 @@ i {
17
17
  }
18
18
 
19
19
  border-radius: 0;
20
- color: #999;
20
+ color: #000;
21
+ opacity: .4;
21
22
  }
22
23
 
23
24
  &.line,