efront 3.14.0 → 3.14.8

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.
@@ -123,17 +123,18 @@ function slider(autoplay, circle = true) {
123
123
  var park = function () {
124
124
  direction = 0;
125
125
  var singleTarget = getSingleTarget();
126
+ var spd = _speed();
126
127
  if (singleTarget) {
127
128
  negative_index = round(negative_index);
128
129
  }
129
130
  else if (delta_negative_index > 0) {
130
- if (negative_index - floor(negative_index) > 0.2 / (1 + 6 * abs(_speed())))
131
+ if (negative_index - floor(negative_index) > 0.2 / (1 + abs(spd)))
131
132
  negative_index = ceil(negative_index);
132
133
  else
133
134
  negative_index = floor(negative_index);
134
135
  }
135
136
  else if (delta_negative_index < 0) {
136
- if (ceil(negative_index) - negative_index > 0.2 / (1 + 6 * abs(_speed())))
137
+ if (ceil(negative_index) - negative_index > 0.2 / (1 + abs(spd)))
137
138
  negative_index = floor(negative_index);
138
139
  else
139
140
  negative_index = ceil(negative_index);
@@ -239,6 +240,7 @@ function slider(autoplay, circle = true) {
239
240
  });
240
241
  moveupon(outter, {
241
242
  start(event) {
243
+ event.preventDefault();
242
244
  cancelAnimationFrame(timer_animate);
243
245
  clearTimeout(timer_playyer);
244
246
  moving = true;
@@ -1,17 +1,13 @@
1
- function speed(time_splitter = 1) {
2
- var lastmoveTime = new Date, speed = 0;
3
- return function (deltay) {
4
- var now = new Date;
5
- var deltat = now - lastmoveTime;
6
- if (arguments.length) {
7
- if (deltat) {
8
- lastmoveTime = now;
9
- if (deltay) speed = speed ? (speed + deltay * time_splitter / deltat) / 2 : deltay * time_splitter / deltat;
10
- else if (deltay === 0) speed = 0;
11
- }
12
- } else if (deltat > 120) {
13
- speed = 0;
1
+
2
+ function speed() {
3
+ var speed = new Speed();
4
+ return function (a) {
5
+ var now = performance.now ? performance.now() : Date.now();
6
+ if (isFinite(a)) {
7
+ if (a === 0) speed.reset();
8
+ else speed.write([a], now);
9
+ return a;
14
10
  }
15
- return speed;
11
+ return speed.read(now)[0];
16
12
  };
17
13
  }
@@ -0,0 +1,34 @@
1
+ var s = speed();
2
+ var id = 0;
3
+ var passed = Date.now();
4
+ var test = async function (wait, write = '') {
5
+ var _id = ++id;
6
+ await new Promise(ok => setTimeout(ok, wait));
7
+ if (write) var read = s(write);
8
+ else var read = s();
9
+ var now = Date.now();
10
+ if (passed) var waited = now - passed;
11
+ else waited = 0;
12
+ passed = now;
13
+ console.log({ _id, wait, waited, read, write });
14
+ return read > 0.1;
15
+ };
16
+ await test(10, 20)
17
+ await test(20, 30);
18
+ await test(20, 30);
19
+ await test(20, 30);
20
+ await test(20);
21
+ await test(20);
22
+ await test(20);
23
+ await test(20);
24
+ await test(20);
25
+ await test(20);
26
+ await test(20);
27
+ await test(20);
28
+ await test(20);
29
+ await test(20);
30
+ await test(20);
31
+ await test(20);
32
+ await test(20);
33
+ await test(20);
34
+ while (await test(20));
@@ -1,10 +1,12 @@
1
- <tbody -src="d in data" :style="{'max-height':((innerHeight-46)/32|0)*32+36}">
1
+ <tbody -src="(d,i) in data" :style="tbodyHeight()">
2
2
  <tr thead #adapter insert>
3
+ <td row-index>序号</td>
3
4
  <td -repeat="f in fields track by f.id" :style="{width:f.width}" @dblclick="sort(f)"><i -if="f.icon"
4
5
  -class="f.icon"></i></span><span -if="f.name" -html="f.name"></span>
5
6
  </td>
6
7
  </tr>
7
8
  <tr>
9
+ <td row-index -bind="i+1"></td>
8
10
  <td -repeat="f in fields">
9
11
  <model -if="f.key" :field=f :data=d readonly></model>
10
12
  <a on-click="o.do(d)" -if="!f.key&&f.options&&(!o.when||o.when(d))"
@@ -146,7 +146,6 @@ function enrichField(f) {
146
146
  f.width = width + 60;
147
147
  }
148
148
 
149
-
150
149
  function table(elem) {
151
150
  var tableElement = isElement(elem) ? elem : document.createElement("table");
152
151
  var activeCols = [];
@@ -214,18 +213,21 @@ function table(elem) {
214
213
  table.dragbox = function () {
215
214
  return thead;
216
215
  };
216
+ var tbodyHeight = e => ({ 'max-height': ((innerHeight - getScreenPosition(table).top - 46) / 32 | 0) * 32 + 36 });
217
217
  care(table, function ([fields, data]) {
218
218
  thead = null;
219
- this.innerHTML = template;
220
219
  fields.forEach(enrichField);
220
+ remove(this.children);
221
+ this.innerHTML = template;
222
+
221
223
  render(this, {
222
224
  fields,
223
- tbody: list,
224
- innerHeight: {
225
- valueOf() {
226
- return innerHeight - getScreenPosition(table).top;
227
- }
225
+ tbody() {
226
+ var e = list.apply(null, arguments);
227
+ css(e, tbodyHeight());
228
+ return e;
228
229
  },
230
+ tbodyHeight,
229
231
  data,
230
232
  adapter: null,
231
233
  model,
@@ -250,9 +252,10 @@ function table(elem) {
250
252
  cellMatchManager,
251
253
  function (src, dst, rel, append, parentNode) {
252
254
  if (table.src) {
253
- var [fields] = table.src;
254
- var [f] = fields.splice(src, 1);
255
- fields.splice(dst, 0, f);
255
+ if (src < 1 || dst < 1) return false;
256
+ var fields = parentNode.$scope.fields;
257
+ var [f] = fields.splice(src - 1, 1);
258
+ fields.splice(dst - 1, 0, f);
256
259
  }
257
260
  var children = parentNode.children;
258
261
  var srcElement = children[src];
@@ -10,6 +10,9 @@
10
10
  box-shadow: 1px 0 0 0 #00000033, -1px 0 0 0 #00000033;
11
11
  }
12
12
 
13
+ &:insert {
14
+ background: #999;
15
+ }
13
16
  }
14
17
  }
15
18
 
@@ -25,10 +28,15 @@ table,
25
28
  box-sizing: border-box;
26
29
  }
27
30
 
31
+ * {
32
+ vertical-align: top;
33
+ }
34
+
28
35
  & {
29
36
  outline: 1px solid #0006;
30
37
  }
31
38
 
39
+
32
40
  .y-ing {
33
41
  &:before {
34
42
  content: "";
@@ -91,21 +99,14 @@ table,
91
99
  }
92
100
 
93
101
  &:nth-of-type(odd) {
94
-
95
- >td,
96
- >th {
97
- background-color: #eee;
98
- }
102
+ background-color: #eee;
99
103
  }
100
104
 
101
105
  &:nth-of-type(even) {
102
-
103
- >td,
104
- >th {
105
- background-color: #fff;
106
- }
106
+ background-color: #fff;
107
107
  }
108
108
 
109
+
109
110
  &:hover {
110
111
 
111
112
  >td,
@@ -121,12 +122,28 @@ table,
121
122
  z-index: 1;
122
123
 
123
124
  >td {
124
- background: #6669;
125
- backdrop-filter: blur(20px);
126
125
  z-index: 1;
126
+ background: #999;
127
127
  color: #fff;
128
128
  }
129
129
  }
130
+
131
+ }
132
+
133
+
134
+ tr {
135
+
136
+ >th,
137
+ >td {
138
+ background: inherit;
139
+
140
+ &[row-index] {
141
+ user-select: none;
142
+ // pointer-events: none;
143
+ background: #fff;
144
+ text-align: right;
145
+ }
146
+ }
130
147
  }
131
148
 
132
149
  [thead] {
@@ -10,8 +10,6 @@
10
10
  background-color: inherit;
11
11
  color: inherit;
12
12
  padding-right: 10px;
13
- padding-top: 4px;
14
- padding-bottom: 4px;
15
13
  box-shadow: none;
16
14
 
17
15
  &.line,
@@ -1,11 +1,5 @@
1
1
  function ybox(generator) {
2
- var scrollY = vscroll.Y;
3
- var abs = Math.abs;
4
- var sqrt = Math.sqrt;
5
- var sign = Math.sign || function (a) {
6
- return +a > 0 ? 1 : -a > 0 ? -1 : 0;
7
- };
8
- var { min, max } = Math;
2
+ var scrollY = inertia(vscroll.Y);
9
3
  var _box;
10
4
  if (isNode(generator)) {
11
5
  _box = generator;
@@ -31,57 +25,34 @@ function ybox(generator) {
31
25
  }
32
26
  return _box.scrollTop;
33
27
  };
34
- _box.stopY = _box.stopY || function (stopedY) {
35
- if (isNumber(stopedY)) {
36
- return stopedY;
37
- }
38
- return _box.Top();
39
- };
40
28
  _box.scrollY = function (deltay, useIncrease = true) {
41
29
  var _Top = _box.Top();
42
30
  var top = _Top + deltay;
43
31
  var height = _box.height();
44
32
  var scrollHeight = _box.Height();
33
+ var r = true;
45
34
  if (top < 0) {
46
- // if (speed > 30) speed = 30;
47
- __speed = __speed >> 1;
48
- useIncrease && _Top <= 0 && increase(top);
49
- top = 0;
50
- _Top = _box.Top(top);
51
- } else if (top + height > scrollHeight) {
52
- // if (speed > 30) speed = 30;
35
+ if (useIncrease && _Top <= 0) {
36
+ r = increase(top);
37
+ }
38
+ _box.Top(0);
39
+ } else if (top + height >= scrollHeight) {
53
40
  if (top + height - scrollHeight > increase_height) {
54
41
  top = increase_height + scrollHeight - height;
55
42
  }
56
- __speed = __speed >> 1;
57
- useIncrease && _Top + height >= scrollHeight && increase(top + height - scrollHeight);
58
- _Top = _box.Top(top);
43
+ if (useIncrease && top + height >= scrollHeight) {
44
+ r = increase(top + height - scrollHeight);
45
+ }
46
+ _box.Top(top);
59
47
  } else {
60
- _Top = _box.Top(top);
48
+ r = top !== _box.Top(top);
61
49
  increase(deltay, true);
62
50
  }
63
- return _Top;
64
- };
65
- var __speed = 0;
66
- var smooth = function (useIncrease = true) {
67
- var abs_speed = abs(__speed << 2) / time_splitter;
68
- var abs_speed = abs(__speed << 2) / time_splitter;
69
- if (abs_speed < 1) {
70
- __speed = _speed(0);
71
- decrease();
72
- return;
73
- }
74
- onclick.preventClick = true;
75
- smooth_timer = requestAnimationFrame(() => smooth(useIncrease));
76
- scrollY.call(_box, -__speed, useIncrease);
77
- __speed = __speed - sign(__speed) * (abs_speed - sqrt(abs_speed) * sqrt(abs_speed - 1));
51
+ return r;
78
52
  };
79
53
  var increaser_t = document.createElement("insert");
80
54
  addClass(increaser_t, 'y-insert');
81
55
  var increaser_b = increaser_t.cloneNode();
82
- var decrease_timer = 0;
83
- var time_splitter = 16;
84
- var _speed = speed(time_splitter);
85
56
  var increase_height = calcPixel(100);
86
57
  var _decrease = function (increaser) {
87
58
  var height = parseInt(increaser.height);
@@ -100,16 +71,26 @@ function ybox(generator) {
100
71
  }
101
72
  increaser.height = height = height > 16 ? (height * 2 + 6) / 3 : height >> 1;
102
73
  increaser.style.height = fromOffset(height | 0);
74
+ return height;
75
+ }
76
+ if (increaser.height) {
77
+ increaser.height = 0;
78
+ increaser.style.height = 0;
103
79
  return 1;
104
80
  }
105
- increaser.height = 0;
106
- increaser.style.height = 0;
107
81
  remove(increaser);
108
82
  return 0;
109
83
  };
84
+ var stop = _box.stopY;
85
+ var stop2 = lazy(function () {
86
+ scrollY.smooth(stop);
87
+ }, 310);
110
88
  var decrease = function () {
111
- if (_decrease(increaser_t) + _decrease(increaser_b)) decrease_timer = requestAnimationFrame(decrease);
112
- else if (_box.stopY() - _box.Top()) decrease_timer = requestAnimationFrame(decrease);
89
+ var res = _decrease(increaser_t) + _decrease(increaser_b);
90
+ if (!res) {
91
+ scrollY.smooth(stop);
92
+ }
93
+ return true;
113
94
  };
114
95
  var increase = function (deltaY, minusOnly) {
115
96
  var t_height = increaser_t.height || 0;
@@ -127,15 +108,9 @@ function ybox(generator) {
127
108
  increaser_b.height = 0;
128
109
  increaser_b.style.height = 0;
129
110
  appendChild(_box, increaser_b);
130
- var deltaMargin = _box.scrollHeight - increaser_b.offsetTop;
111
+ var deltaMargin = _box.scrollHeight - increaser_b.offsetTop - parseFloat(getComputedStyle(_box).paddingBottom);
131
112
  if (deltaMargin > 0) {
132
113
  increaser_b.style.marginTop = fromOffset(deltaMargin);
133
- var paddingBottom = getComputedStyle(_box).paddingBottom;
134
- if (paddingBottom) {
135
- paddingBottom = "-" + paddingBottom;
136
- paddingBottom = paddingBottom.replace(/^\-{2}/, "");
137
- }
138
- increaser_b.style.marginBottom = paddingBottom;
139
114
  }
140
115
  }
141
116
  }
@@ -145,14 +120,13 @@ function ybox(generator) {
145
120
  if (t_height < 0) t_height = 0;
146
121
  if (!minusOnly || b_height < increaser_b.height) increaser_b.height = b_height, increaser_b.style.height = fromOffset(b_height);
147
122
  if (!minusOnly || t_height < increaser_t.height) increaser_t.height = t_height, increaser_t.style.height = fromOffset(t_height);
123
+ return t_height < increase_height && b_height < increase_height;
148
124
  };
149
125
  if (/Edge|Trident/i.test(navigator.userAgent)) {
150
126
  // ie
151
127
  addClass(_box, "trident");
152
128
  } else {
153
129
  onmousewheel(_box, function (event) {
154
- cancelAnimationFrame(smooth_timer);
155
- cancelAnimationFrame(decrease_timer);
156
130
  var deltay = -event.deltaY;
157
131
  if (event.moveLocked) return;
158
132
  event.moveLocked = true;
@@ -165,33 +139,28 @@ function ybox(generator) {
165
139
  if (box === _box) {
166
140
  event.preventDefault();
167
141
  scrollY.call(_box, -deltay, false);
168
- smooth(false);
142
+ stop2();
169
143
  }
170
144
  });
171
145
  bindtouch(_box, {
172
146
  start() {
173
- cancelAnimationFrame(smooth_timer);
174
- cancelAnimationFrame(decrease_timer);
175
- _speed(0);
147
+ scrollY.reset();
176
148
  },
177
149
  move(scrolled) {
178
150
  var y = -this.Top();
179
151
  if (scrolled) {
180
152
  var { deltay } = scrolled;
181
- __speed = _speed(deltay);
182
153
  scrollY.call(this, -deltay);
183
154
  y += deltay;
184
155
  }
185
156
  return { y };
186
157
  },
187
158
  end() {
188
- __speed = _speed();
189
- smooth();
159
+ scrollY.smooth(decrease);
190
160
  }
191
161
  }, 'y');
192
162
  }
193
163
 
194
- var smooth_timer;
195
164
  var initScrollId = function () {
196
165
  var temp = this.parentNode;
197
166
  var scrollId = 0;
@@ -203,11 +172,8 @@ function ybox(generator) {
203
172
  }
204
173
  if (isMounted(_box)) initScrollId.call(_box);
205
174
  on("append")(_box, initScrollId);
206
- _box.cancelFrame = function () {
207
- cancelAnimationFrame(smooth_timer);
208
- cancelAnimationFrame(decrease_timer);
209
- __speed = _speed(0);
210
- };
175
+ on("remove")(_box, scrollY.reset);
176
+ _box.cancelFrame = scrollY.reset;
211
177
  preventOverflowScrolling(_box);
212
178
  return _box;
213
179
  }
@@ -2,8 +2,9 @@ var scroll = function () {
2
2
  var scrollY = function (deltay, useIncrease) {
3
3
  deltay = scrollOutside.call(this, deltay);
4
4
  if (isFunction(this.scrollY)) return this.scrollY(deltay, useIncrease);
5
- else this.scrollTop += deltay;
6
- return this.scrollTop;
5
+ var scrollTop = this.scrollTop;
6
+ this.scrollTop += deltay;
7
+ if (this.scrollTop === scrollTop) return false;
7
8
  };
8
9
 
9
10
  var Height = function () {
@@ -1,4 +1,6 @@
1
- var count=0x10000000;//弹出式菜单或窗口的zIndex起点
2
- function zIndex(){
3
- return count++;
1
+ var count = 0x10000000;//弹出式菜单或窗口的zIndex起点
2
+ function zIndex(inc = 1) {
3
+ inc |= 0;
4
+ if (inc > 0) count += inc;
5
+ return count;
4
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.14.0",
3
+ "version": "3.14.8",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {