efront 3.14.2 → 3.14.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.
@@ -1,10 +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
- };
2
+ var scrollY = inertia(vscroll.Y);
8
3
  var _box;
9
4
  if (isNode(generator)) {
10
5
  _box = generator;
@@ -30,57 +25,34 @@ function ybox(generator) {
30
25
  }
31
26
  return _box.scrollTop;
32
27
  };
33
- _box.stopY = _box.stopY || function (stopedY) {
34
- if (isNumber(stopedY)) {
35
- return stopedY;
36
- }
37
- return _box.Top();
38
- };
39
28
  _box.scrollY = function (deltay, useIncrease = true) {
40
29
  var _Top = _box.Top();
41
30
  var top = _Top + deltay;
42
31
  var height = _box.height();
43
32
  var scrollHeight = _box.Height();
33
+ var r = true;
44
34
  if (top < 0) {
45
- // if (speed > 30) speed = 30;
46
- __speed = __speed >> 1;
47
- useIncrease && _Top <= 0 && increase(top);
48
- top = 0;
49
- _Top = _box.Top(top);
50
- } else if (top + height > scrollHeight) {
51
- // 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) {
52
40
  if (top + height - scrollHeight > increase_height) {
53
41
  top = increase_height + scrollHeight - height;
54
42
  }
55
- __speed = __speed >> 1;
56
- useIncrease && _Top + height >= scrollHeight && increase(top + height - scrollHeight);
57
- _Top = _box.Top(top);
43
+ if (useIncrease && top + height >= scrollHeight) {
44
+ r = increase(top + height - scrollHeight);
45
+ }
46
+ _box.Top(top);
58
47
  } else {
59
- _Top = _box.Top(top);
48
+ r = top !== _box.Top(top);
60
49
  increase(deltay, true);
61
50
  }
62
- return _Top;
63
- };
64
- var __speed = 0;
65
- var smooth = function smooth(useIncrease = true) {
66
- var abs_speed = abs(__speed << 2) / time_splitter;
67
- var abs_speed = abs(__speed << 2) / time_splitter;
68
- if (abs_speed < 1) {
69
- __speed = _speed(0);
70
- decrease();
71
- return;
72
- }
73
- onclick.preventClick = true;
74
- smooth_timer = requestAnimationFrame(() => smooth(useIncrease));
75
- scrollY.call(_box, -__speed, useIncrease);
76
- __speed = __speed - sign(__speed) * (abs_speed - sqrt(abs_speed) * sqrt(abs_speed - 1));
51
+ return r;
77
52
  };
78
53
  var increaser_t = document.createElement("insert");
79
54
  addClass(increaser_t, 'y-insert');
80
55
  var increaser_b = increaser_t.cloneNode();
81
- var decrease_timer = 0;
82
- var time_splitter = 16;
83
- var _speed = speed(time_splitter);
84
56
  var increase_height = calcPixel(100);
85
57
  var _decrease = function (increaser) {
86
58
  var height = parseInt(increaser.height);
@@ -99,31 +71,26 @@ function ybox(generator) {
99
71
  }
100
72
  increaser.height = height = height > 16 ? (height * 2 + 6) / 3 : height >> 1;
101
73
  increaser.style.height = fromOffset(height | 0);
74
+ return height;
75
+ }
76
+ if (increaser.height) {
77
+ increaser.height = 0;
78
+ increaser.style.height = 0;
102
79
  return 1;
103
80
  }
104
- increaser.height = 0;
105
- increaser.style.height = 0;
106
81
  remove(increaser);
107
82
  return 0;
108
83
  };
109
- var stop_timer = 0, stop_id = 0, cancel_id = 0;
110
- var stop = lazy(function stop() {
111
- if (cancel_id !== stop_id) return;
112
- if (Math.abs(_box.stopY() - _box.Top() )> 0.0001) stop_timer = setTimeout(stop, 16);
84
+ var stop = _box.stopY;
85
+ var stop2 = lazy(function () {
86
+ scrollY.smooth(stop);
113
87
  }, 310);
114
- var cancelFrame = function () {
115
- __speed = _speed(0);
116
- clearTimeout(stop_timer);
117
- cancelAnimationFrame(smooth_timer);
118
- cancelAnimationFrame(decrease_timer);
119
- return ++cancel_id;
120
- };
121
88
  var decrease = function () {
122
- if (_decrease(increaser_t) + _decrease(increaser_b)) decrease_timer = requestAnimationFrame(decrease);
123
- else {
124
- stop_id = cancel_id;
125
- stop();
89
+ var res = _decrease(increaser_t) + _decrease(increaser_b);
90
+ if (!res) {
91
+ scrollY.smooth(stop);
126
92
  }
93
+ return true;
127
94
  };
128
95
  var increase = function (deltaY, minusOnly) {
129
96
  var t_height = increaser_t.height || 0;
@@ -141,15 +108,9 @@ function ybox(generator) {
141
108
  increaser_b.height = 0;
142
109
  increaser_b.style.height = 0;
143
110
  appendChild(_box, increaser_b);
144
- var deltaMargin = _box.scrollHeight - increaser_b.offsetTop;
111
+ var deltaMargin = _box.scrollHeight - increaser_b.offsetTop - parseFloat(getComputedStyle(_box).paddingBottom);
145
112
  if (deltaMargin > 0) {
146
113
  increaser_b.style.marginTop = fromOffset(deltaMargin);
147
- var paddingBottom = getComputedStyle(_box).paddingBottom;
148
- if (paddingBottom) {
149
- paddingBottom = "-" + paddingBottom;
150
- paddingBottom = paddingBottom.replace(/^\-{2}/, "");
151
- }
152
- increaser_b.style.marginBottom = paddingBottom;
153
114
  }
154
115
  }
155
116
  }
@@ -159,14 +120,13 @@ function ybox(generator) {
159
120
  if (t_height < 0) t_height = 0;
160
121
  if (!minusOnly || b_height < increaser_b.height) increaser_b.height = b_height, increaser_b.style.height = fromOffset(b_height);
161
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;
162
124
  };
163
125
  if (/Edge|Trident/i.test(navigator.userAgent)) {
164
126
  // ie
165
127
  addClass(_box, "trident");
166
128
  } else {
167
129
  onmousewheel(_box, function (event) {
168
- cancelAnimationFrame(smooth_timer);
169
- cancelAnimationFrame(decrease_timer);
170
130
  var deltay = -event.deltaY;
171
131
  if (event.moveLocked) return;
172
132
  event.moveLocked = true;
@@ -179,31 +139,28 @@ function ybox(generator) {
179
139
  if (box === _box) {
180
140
  event.preventDefault();
181
141
  scrollY.call(_box, -deltay, false);
182
- smooth(false);
142
+ stop2();
183
143
  }
184
144
  });
185
145
  bindtouch(_box, {
186
146
  start() {
187
- cancelFrame();
147
+ scrollY.reset();
188
148
  },
189
149
  move(scrolled) {
190
150
  var y = -this.Top();
191
151
  if (scrolled) {
192
152
  var { deltay } = scrolled;
193
- __speed = _speed(deltay);
194
153
  scrollY.call(this, -deltay);
195
154
  y += deltay;
196
155
  }
197
156
  return { y };
198
157
  },
199
158
  end() {
200
- __speed = _speed();
201
- smooth();
159
+ scrollY.smooth(decrease);
202
160
  }
203
161
  }, 'y');
204
162
  }
205
163
 
206
- var smooth_timer;
207
164
  var initScrollId = function () {
208
165
  var temp = this.parentNode;
209
166
  var scrollId = 0;
@@ -215,7 +172,8 @@ function ybox(generator) {
215
172
  }
216
173
  if (isMounted(_box)) initScrollId.call(_box);
217
174
  on("append")(_box, initScrollId);
218
- _box.cancelFrame = cancelFrame;
175
+ on("remove")(_box, scrollY.reset);
176
+ _box.cancelFrame = scrollY.reset;
219
177
  preventOverflowScrolling(_box);
220
178
  return _box;
221
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.2",
3
+ "version": "3.14.11",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {