efront 3.16.0 → 3.17.2

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,15 +1,16 @@
1
+ "use strict";
1
2
  var oncetree = {};
2
3
  function _once(key) {
3
4
  if (oncetree[key]) return oncetree[key];
4
- return oncetree[key] = function (target, handler) {
5
- var off = on(key)(target, function (event) {
5
+ return oncetree[key] = function (target, handler, firstmost) {
6
+ var off = on(key).call(this, target, function (event) {
6
7
  off();
7
8
  return handler.call(this, event);
8
- });
9
+ }, firstmost);
9
10
  return off;
10
11
  };
11
12
  }
12
- function once(key, target, handler) {
13
- if (isFunction(handler) && isNode(target)) return _once(key)(target, handler);
13
+ function once(key, target, handler, firstmost) {
14
+ if (isFunction(handler) && isNode(target)) return _once(key).call(this, target, handler, firstmost);
14
15
  return _once(key);
15
16
  }
@@ -9,5 +9,5 @@ function onmounted(target, handle) {
9
9
  if (isMounted(target)) {
10
10
  handle.call(target);
11
11
  }
12
- onappend(target, handle);
12
+ on("mounted")(target, handle);
13
13
  }
@@ -228,7 +228,7 @@ var createIf = function (search, id = 0) {
228
228
  appendChild.before(this, element);
229
229
  if (element.renderid < 0) {
230
230
  element.renderid = id;
231
- elements[cx] = render(element);
231
+ elements[cx] = render(element, this.$scope, this.$parentScopes);
232
232
  }
233
233
  }
234
234
  else {
@@ -599,7 +599,7 @@ function getFromScopes(key, scope, parentScopes) {
599
599
  }
600
600
  }
601
601
 
602
- function renderElement(element, scope = element.$scope, parentScopes = element.$parentScopes) {
602
+ function renderElement(element, scope = element.$scope, parentScopes = element.$parentScopes, eager) {
603
603
  if (!isNode(element) && element.length) {
604
604
  return [].concat.apply([], element).map(function (element) {
605
605
  return renderElement(element, scope, parentScopes);
@@ -699,10 +699,10 @@ function renderElement(element, scope = element.$scope, parentScopes = element.$
699
699
  }
700
700
  ons.forEach(([on, key, value]) => on.call(element, key, [withContext, value]));
701
701
  if (element.renders.length) {
702
- rebuild(element);
703
- onappend(element, addRenderElement);
702
+ onmounted(element, addRenderElement);
704
703
  onremove(element, removeRenderElement);
705
704
  if (isMounted(element) || element.renderid > 1) addRenderElement.call(element);
705
+ else if (eagermount) rebuild(element);
706
706
  }
707
707
  if (elementid) scope[elementid] = element;
708
708
  for (var id of ids) {
@@ -797,13 +797,26 @@ function renderStructure(element, scope, parentScopes = []) {
797
797
  if (!element.$struct) element.$struct = { ons, copys, binds, attrs: attr1, props, context: withContext, ids };
798
798
  if (element.renderid <= -1) createStructure.call(element, types.if, types.repeat, withContext);
799
799
  }
800
- function render(element, scope, parentScopes) {
800
+ var eagermount = false, renderlock = false;
801
+ function render(element, scope, parentScopes, lazy = true) {
801
802
  var if_top_length = if_top.length;
803
+ var haslock = false;
804
+ if (!renderlock) {
805
+ haslock = true;
806
+ renderlock = true;
807
+ if (isBoolean(scope) && arguments.length === 2) lazy = +scope, scope = undefined;
808
+ else if (isBoolean(parentScopes) && arguments.length === 3) lazy = +parentScopes, parentScopes = undefined;
809
+ else lazy = +lazy;
810
+ eagermount = !lazy;
811
+ }
802
812
  var e = renderElement(element, scope, parentScopes);
813
+ if (haslock) {
814
+ renderlock = false;
815
+ eagermount = false;
816
+ }
803
817
  if (if_top_length < if_top.length) if_top.splice(if_top_length, if_top.length - if_top_length);
804
818
  return e;
805
819
  }
806
-
807
820
  var digest = lazy(refresh, -{});
808
821
  render.digest = render.apply = render.refresh = digest;
809
822
  render.parseRepeat = parseRepeat;
@@ -8,6 +8,7 @@ extend(renderDefaults, {
8
8
  go: zimoli.go,
9
9
  care,
10
10
  cast,
11
+ container,
11
12
  input,
12
13
  padding,
13
14
  block,
@@ -142,6 +142,7 @@ function resize(elem, initialEvent) {
142
142
  }
143
143
  moveupon(window, handle);
144
144
 
145
+
145
146
  resize.on = function (elem, dragHandle) {
146
147
  if (elem) {
147
148
  elem.dragHandle = dragHandle;
@@ -150,6 +151,23 @@ resize.on = function (elem, dragHandle) {
150
151
  var off = onmousemove(window, getResizer);
151
152
  onremove(elem, off);
152
153
  });
154
+ var computed = getComputedStyle(elem);
155
+ var resizeh = function () {
156
+ var elem = this;
157
+ if (elem.scrollWidth > elem.clientWidth) {
158
+ css(elem, { width: elem.offsetWidth });
159
+ dispatch(elem, 'resize');
160
+ }
161
+ if (elem.scrollHeight > elem.clientHeight) {
162
+ css(elem, { height: elem.offsetHeight });
163
+ dispatch(elem, 'resize');
164
+ }
165
+ if (unbind && parseInt(computed.height) && parseInt(computed.width)) {
166
+ unbind();
167
+ unbind = null;
168
+ };
169
+ }
170
+ if (!parseInt(computed.height) || !parseInt(computed.width)) var unbind = bind('render')(elem, resizeh);
153
171
  if (!~resizingElements.indexOf(elem)) {
154
172
  resizingElements.push(elem);
155
173
  once('remove')(elem, function () {
@@ -2,7 +2,7 @@ var scrollbary = function () {
2
2
  var reshape = function (scrollHeight, offsetHeight) {
3
3
  var target = this.target;
4
4
  if (target) {
5
- this.style.height = target.offsetHeight + "px";
5
+ css(this, { height: target.offsetHeight });
6
6
  }
7
7
  var scrollbarHeight = this.offsetHeight;
8
8
  var ratio = offsetHeight / scrollHeight;
@@ -10,11 +10,14 @@ var scrollbary = function () {
10
10
  if (thumbHeight < 14) thumbHeight = 14;
11
11
  if (thumbHeight < 0) thumbHeight = 0;
12
12
  this.restHeight = scrollHeight - offsetHeight;
13
- this.thumb.style.height = thumbHeight + "px";
13
+ css(this.thumb, {
14
+ height: thumbHeight
15
+ });
14
16
  if (thumbHeight >= this.clientHeight) {
15
17
  this.style.opacity = 0;
16
18
  } else {
17
19
  this.style.opacity = 1;
20
+ this.autoshow();
18
21
  }
19
22
  };
20
23
  var getTop = function () {
@@ -59,7 +62,7 @@ var scrollbary = function () {
59
62
  deltaY = targetY - thumbTop;
60
63
  moving.y += deltaY;
61
64
  if (targetY !== thumbTop) {
62
- thumb.style.top = targetY + "px";
65
+ css(thumb, { top: targetY });
63
66
  dispatch(target, "change");
64
67
  }
65
68
  };
@@ -138,7 +141,7 @@ var scrollbary = function () {
138
141
  return { Height, height };
139
142
  };
140
143
 
141
- function bindTarget(_container) {
144
+ function bindTarget(_container, followResize = _container) {
142
145
  var _scrollbar = this;
143
146
  _container.with = _scrollbar;
144
147
  onappend(_container, _scrollbar.reshape);
@@ -146,24 +149,33 @@ var scrollbary = function () {
146
149
  on("scroll")(_container, function () {
147
150
  var top = getTargetTop(_container);
148
151
  _scrollbar.scrollTo(top);
152
+ _scrollbar.autoshow();
149
153
  });
150
154
  on("change")(_scrollbar, function () {
151
155
  var top = _scrollbar.Top();
152
156
  setTargetTop(_container, top);
153
157
  });
154
- _scrollbar.reshape();
158
+ if (followResize) on("resize")(followResize, _scrollbar.reshape);
155
159
  }
156
- function scrollbar() {
157
- var _scrollbar = div();
160
+ function scrollbar(elem) {
161
+ var _scrollbar = elem || document.createElement("scrollbar");
158
162
  _scrollbar.reshape = function () {
159
163
  var _container = _scrollbar.target;
160
164
  var { Height, height } = getTargetHeight(_container);
161
165
  reshape.call(_scrollbar, Height, height);
162
166
  };
163
167
  _scrollbar.scrollTo = scrollTo;
164
- var _handler = div();
168
+ var _handler = document.createElement("scrollbar-thumb");
165
169
  _handler.className = "thumb";
166
170
  _scrollbar.Top = getTop;
171
+ _scrollbar.autohide = lazy(function () {
172
+ this.thumb.style.opacity = 0;
173
+ }, 600);
174
+ _scrollbar.autoshow = function () {
175
+ this.autohide();
176
+ this.thumb.style.opacity = 1;
177
+ };
178
+
167
179
  moveupon(_handler, {
168
180
  start: mousedown,
169
181
  move: mousemove,
@@ -1,10 +1,31 @@
1
1
  & {
2
2
  position: absolute;
3
- width: 14px;
3
+ width: 6px;
4
4
  background-color: rgba(0, 0, 0, .1);
5
5
  border-radius: 7px;
6
6
  height: 100px;
7
+ border-left: 3px solid transparent;
8
+
9
+ &:hover {
10
+ >.thumb {
11
+ opacity: 1 !important;
12
+ overflow: visible;
13
+ }
14
+ }
15
+
7
16
  >.thumb {
17
+ &:after {
18
+ position: absolute;
19
+ top: 0;
20
+ bottom: 0;
21
+ left: -4px;
22
+ right: -4px;
23
+ width: auto;
24
+ display: block;
25
+ content: "";
26
+ }
27
+
28
+ transition: opacity .2s;
8
29
  position: absolute;
9
30
  border-radius: 7px;
10
31
  height: 100%;
@@ -132,7 +132,7 @@ function tree() {
132
132
  }
133
133
  var tabs = new Array(com.tab + 1).join("<t></t>");
134
134
  if (isFunction(generator)) {
135
- var elem = generator(index, com instanceof Item ? com.value : com);
135
+ var elem = generator(index, com instanceof Item ? com.value : com, com);
136
136
  if (!elem) return;
137
137
  span = document.createElement('span');
138
138
  span.innerHTML = tabs;
@@ -222,9 +222,9 @@ function tree() {
222
222
  };
223
223
  com.target = _div;
224
224
  _div.refresh();
225
- onclick(_div, function () {
225
+ onclick(_div, function (event) {
226
226
  var isClosed = com.isClosed();
227
- if (!active(banner, com.value, com, _div)) {
227
+ if (!active(banner, com.value, com, element.$src ? createItemTarget.call(element, com.value) : _div)) {
228
228
  return;
229
229
  }
230
230
  if (isClosed === com.isClosed() && com.length) {
@@ -84,7 +84,7 @@ function ybox(generator) {
84
84
  var stop = _box.stopY;
85
85
  var stop2 = lazy(function () {
86
86
  scrollY.smooth(stop);
87
- }, 310);
87
+ }, 60);
88
88
  var decrease = function () {
89
89
  var res = _decrease(increaser_t) + _decrease(increaser_b);
90
90
  if (!res) {
@@ -126,7 +126,12 @@ function ybox(generator) {
126
126
  // ie
127
127
  addClass(_box, "trident");
128
128
  } else {
129
+ var wheelTime = 0;
129
130
  onmousewheel(_box, function (event) {
131
+ if (event.timeStamp - wheelTime > 60 && Math.abs(event.deltaY) < 12) {
132
+ wheelTime = event.timeStamp;
133
+ return;
134
+ }
130
135
  var deltay = -event.deltaY;
131
136
  if (event.moveLocked) return;
132
137
  event.moveLocked = true;
@@ -137,7 +142,6 @@ function ybox(generator) {
137
142
  box = getTargetIn(e => e === _box || /^(?:auto|scroll)$/i.test(getComputedStyle(e).overflowY) && e.scrollHeight - e.scrollTop > e.clientHeight, event.target);
138
143
  }
139
144
  if (box === _box) {
140
- event.preventDefault();
141
145
  scrollY.call(_box, -deltay, false);
142
146
  stop2();
143
147
  }
@@ -169,7 +173,7 @@ function ybox(generator) {
169
173
  temp = temp.parentNode;
170
174
  }
171
175
  this.YScrollBoxId = +scrollId + 1;
172
- }
176
+ };
173
177
  if (isMounted(_box)) initScrollId.call(_box);
174
178
  on("append")(_box, initScrollId);
175
179
  on("remove")(_box, scrollY.reset);
@@ -145,7 +145,7 @@ function go(pagepath, args, history_name, oldpagepath) {
145
145
  history_name.activate = pagepath;
146
146
  history_name.activateNode = _page;
147
147
  }
148
- if (isString(pagepath)) {
148
+ else if (isString(pagepath)) {
149
149
  if (fullfill_is_dispatched > 0) return;
150
150
  fullfill_is_dispatched = 1;
151
151
  var event = createEvent("zimoli");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.16.0",
3
+ "version": "3.17.2",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {