efront 3.35.5 → 3.35.7

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,5 +1,5 @@
1
1
  var page = document.createElement("page");
2
- page.initialStyle = 'transform:scale(.9);opacity:0;';
2
+ page.initialStyle = 'transform:scale(1.1);opacity:0;';
3
3
  var tags = "新歌:song/list:音乐总有新玩法,排行:rank/list:排行榜 - 酷狗音乐,歌单:plist/list:歌单 - 酷狗音乐,歌手:singer/keywords:歌手分类 - 酷狗音乐".split(",").map(function (tag, cx) {
4
4
  var [str, url, title] = tag.split(":");
5
5
  var label = {
@@ -4,5 +4,6 @@ data.getApi("kuwo-token").then(function (api) {
4
4
  if (!token) cross("get", api.base);
5
5
  });
6
6
  zimoli.switch("", null, "/home");
7
+ zimoli.enableTouchBack();
7
8
  css("body", "background-color:#323336;");
8
9
  zimoli();
@@ -36,6 +36,7 @@ var fields = refilm`
36
36
  if (p) p = ":" + p;
37
37
  try {
38
38
  var ip = data.ip;
39
+ if (!ip) return;
39
40
  if (/^::ffff:\d+\.\d+\.\d+\.\d+$/i.test(ip)) {
40
41
  ip = ip.slice(7);
41
42
  }
@@ -309,6 +309,7 @@ function cross_(jsonp, digest = noop, method, url, headers) {
309
309
  };
310
310
  var fire = async function (code) {
311
311
  if (!~requests.indexOf(xhr)) return;
312
+ prepareHeaders();
312
313
  xhr.method = method;
313
314
  xhr.url = url;
314
315
  xhr.encrypt = code;
@@ -365,25 +366,28 @@ function cross_(jsonp, digest = noop, method, url, headers) {
365
366
  }
366
367
  var setRequestHeader = xhr.setRequestHeader;
367
368
  var realHeaders = Object.create(null);
368
- var cookie_ = this.hostCookie(xhr);
369
- var _cookies = cookie_.getCookies(originDomain);
370
- var _headers = {};
371
- if (_cookies) {
372
- _headers.Cookie = _cookies;
373
- }
374
- var cookobj = null;
375
- for (var k in headers) {
376
- if (/^\$/.test(headers[k])) {
377
- var k2 = headers[k].slice(1);
378
- if (!cookobj) cookobj = _cookies ? parseKV(_cookies, ';') : {};
379
- if (k2 in cookobj) {
380
- _headers[k] = cookobj[k2];
381
- }
369
+ var cookie_;
370
+ var prepareHeaders = () => {
371
+ cookie_ = this.hostCookie(xhr);
372
+ var _cookies = cookie_.getCookies(originDomain);
373
+ if (_cookies) {
374
+ _headers.Cookie = _cookies;
382
375
  }
383
- else {
384
- _headers[k] = headers[k];
376
+ var cookobj = null;
377
+ for (var k in headers) {
378
+ if (/^\$/.test(headers[k])) {
379
+ var k2 = headers[k].slice(1);
380
+ if (!cookobj) cookobj = _cookies ? parseKV(_cookies, ';') : {};
381
+ if (k2 in cookobj) {
382
+ _headers[k] = cookobj[k2];
383
+ }
384
+ }
385
+ else {
386
+ _headers[k] = headers[k];
387
+ }
385
388
  }
386
- }
389
+ };
390
+ var _headers = {};
387
391
  if (/^[mc]/i.test(method)) {
388
392
  _headers["User-Agent"] = /^m/i.test(method)
389
393
  ? "efront/3.25 (iPhone) Safari/602.1"
package/coms/kugou/api.js CHANGED
@@ -11,7 +11,7 @@
11
11
  "plist-index": "get:[].panel-img-list%20li plist/index#href=a!href&=a!href\\plist-info&imgurl=img!_src&name=.panel-img-content-first|innerText&count=.panel-img-content-sub|innerText",
12
12
  "plist-info": "mget:[].panel-songslist%20li plist/list/:id/#name=.panel-songs-item-name|innerText&data=.panel-songs-item-download/innerText",
13
13
  "search-hot": "get api/v3/search/hot?format=json&plat=0&count=30",
14
- "singer-class": "get:[].bd%20li singer/class#href=a!href&=a!href\\singer-list&name=a|innerText&group=?parentNode",
14
+ "singer-class": "get:[].bd%20.tab singer/list#href=!href&=!href\\singer-list&name=|innerText&group=?parentNode",
15
15
  "singer-list": "get:[].singer-img-list>li singer/list/:id#href=a!href&=a!href\\singer-info0&imgurl=img!_src&name=p|innerText",
16
16
  "singer-info0": "mget:[].singer-songs-list>li singer/info/:id#hash=!id&singer=.singer-name|innerText&name=.song-name|innerText&data=em/innerText"
17
17
  },
@@ -23,11 +23,12 @@ function Main(dataid, datapath, titleid) {
23
23
  datas: []
24
24
  });
25
25
  bindScroll(_titlebar, page);
26
- var loadedId;
26
+ var loadedId, requested = false;
27
27
  function main(params) {
28
28
  var { _text, title = "", name = _text || title, id } = params;
29
- if (loadedId !== id) {
29
+ if (!requested || loadedId !== id) {
30
30
  loadedId = id;
31
+ requested = true;
31
32
  var ranklist = data.from(dataid, {
32
33
  id
33
34
  }, parseSongsList);
@@ -6,6 +6,7 @@
6
6
  bottom: -60px;
7
7
  top: 0;
8
8
  height: auto;
9
+ background: #323336;
9
10
  }
10
11
  &+.titlebar>back{
11
12
  height: 44px;
@@ -14,7 +14,7 @@ var change = async function (data) {
14
14
  }
15
15
  zimoli.global(data, this);
16
16
  }
17
- else zimoli.go(data, this.params, this);
17
+ else if (isString(data) || +data < 0) zimoli.go(data, this.params, this);
18
18
  };
19
19
  var gosrc = function () {
20
20
  var { src } = this;
@@ -59,7 +59,8 @@ cross.setHost = function (host) {
59
59
  host = (/^https/.test(location_href) ? "https://" : "http://") + host;
60
60
  cross_.setHost(host);
61
61
  };
62
- cross.hostCookie = function () {
62
+ cross.hostCookie = function (xhr) {
63
+ if (xhr.cookie) return xhr.cookie;
63
64
  return cookie;
64
65
  };
65
66
  cross.getCookies = function (dp) {
@@ -181,4 +181,7 @@ var css = function (target, oStyle, oValue) {
181
181
  }
182
182
  }
183
183
  else if (isString(target)) cssTargetSelector(target, oStyle, oValue);
184
- };
184
+ };
185
+ css.transformCssKey = transformCssKey;
186
+ css.transformNodeKey = transformNodeKey;
187
+ css.transformValue = transformValue;
@@ -300,7 +300,6 @@ function parseConfig(api) {
300
300
  p = p.slice(1);
301
301
  if (!required[p] && p !== ':') {
302
302
  required.push(p);
303
- required[p] = p;
304
303
  }
305
304
  });
306
305
  return {
@@ -502,7 +501,7 @@ var privates = {
502
501
  if (!required.length && !prepared.length && !autotrim) return params;
503
502
  var params1 = {};
504
503
  required.forEach(k => {
505
- var v = seekResponse(params, required[k]);
504
+ var v = seekResponse(params, required[k] || k);
506
505
  params1[k] = v;
507
506
  });
508
507
  prepared.forEach(k => {
@@ -528,6 +527,7 @@ var privates = {
528
527
  var lacks = required;
529
528
  if (params) {
530
529
  lacks = lacks.filter(k => {
530
+ if (!required[k]) return false;
531
531
  var v = seekResponse(params, required[k]);
532
532
  if (isEmpty(v)) return true;
533
533
  });
@@ -197,7 +197,8 @@ function ylist(container, generator, $Y) {
197
197
  }
198
198
  var indexed_item = getIndexedElement(index) || bottom_item;
199
199
  if (indexed_item) {
200
- list.scrollTop = -getFirstElement(1).offsetTop + indexed_item.offsetTop + indexed_item.offsetHeight * ratio;
200
+ var firstElement = getFirstElement(1) || indexed_item;
201
+ list.scrollTop = -firstElement.offsetTop + indexed_item.offsetTop + indexed_item.offsetHeight * ratio;
201
202
  }
202
203
  };
203
204
  //计算当前高度
@@ -615,9 +616,13 @@ function list() {
615
616
  generator = function () { }
616
617
  }
617
618
  }
618
- if (bindSrc === true) care(container, function () {
619
+ var savedSrc = [];
620
+ if (bindSrc === true) care(container, function (src, old) {
619
621
  var index = container.index();
620
- container.clean();
622
+ if (src !== old) container.clean(), index = 0;
623
+ else container.clean(src, savedSrc);
624
+ savedSrc = src.slice();
625
+ if (index > 0 && index >= src.length) index = src.length - 1;
621
626
  container.go(index || 0);
622
627
  });
623
628
 
@@ -639,13 +644,14 @@ function list() {
639
644
  } else if (bindSrc === true) {
640
645
  container.go(container.index() || 0);
641
646
  }
642
- list.clean = function () {
647
+ list.clean = function (src, old) {
643
648
  var children = (container || list).childNodes;
644
649
  children = Array.prototype.filter.call(children, c => {
645
650
  if (isFinite(c.index)) return true;
646
651
  if (c.nodeType === 1 && c.$comment && isFinite(c.$comment.index)) return true;
647
652
  return false;
648
653
  });
654
+ if (src && old) children = children.filter(c => src[c.index] !== old[c.index]);
649
655
  remove(children);
650
656
  };
651
657
 
@@ -33,9 +33,10 @@ function prompt() {
33
33
  };
34
34
  var buttons = [button("确认"), button("取消", 'white')];
35
35
  if (isFunction(check)) {
36
- var setDisable = function () {
36
+ var setDisable = function (event) {
37
+ if (oked || ohed) return;
37
38
  var valid = validate(ipt.value, check, tip);
38
- attr(body, "error", !valid);
39
+ if (event) attr(body, "error", !valid);
39
40
  attr(buttons[0], 'disabled', !valid);
40
41
  };
41
42
  on('keyup')(ipt, setDisable);
@@ -49,7 +50,7 @@ function prompt() {
49
50
  var c = confirm(msg, body, buttons, function (_) {
50
51
  if (oked || ohed) return;
51
52
  if (_ === buttons[0]) {
52
- if (check && validate(ipt.value, check, tip)) return false;
53
+ if (check && !validate(ipt.value, check, tip)) return false;
53
54
  oked = true;
54
55
  } else {
55
56
  ohed = true;
@@ -65,11 +66,8 @@ function prompt() {
65
66
  on("mousedown")(c, e => e.target !== ipt && e.preventDefault() | ipt.focus());
66
67
  on("keydown.enter")(c, function (event) {
67
68
  if (event.defaultPrevented) return;
68
- if (check && check(ipt.value) === false) return;
69
69
  event.preventDefault();
70
- oked = true;
71
- remove(c);
72
- fire();
70
+ buttons[0].click();
73
71
  });
74
72
  c.then = function (ok, oh) {
75
73
  oks.push(ok);
@@ -170,9 +170,10 @@ function main() {
170
170
  switch (target) {
171
171
  case this.children[0]:
172
172
  var a = prompt("请输入", a => {
173
+ if (!a) return false;
174
+ console.log(itemMap, a);
173
175
  if (a in itemMap) {
174
- alert(`选项 ${a} 已存在!`);
175
- return false;
176
+ return `选项 ${a} 已存在!`;
176
177
  }
177
178
  });
178
179
  page.with = a;
@@ -192,6 +193,7 @@ function main() {
192
193
  var edit = selectListEdit(options.slice(0));
193
194
  page.with = edit;
194
195
  on("remove")(edit, function () {
196
+ itemMap = Object.create(null);
195
197
  page.with = null;
196
198
  children.splice(0, children.length);
197
199
  children.push.apply(children, edit.$scope.options.map(o => ({ key: o.key || o.value, name: o.name || o.innerHTML })))
@@ -472,8 +472,10 @@ function table(elem) {
472
472
  if (_vbox) _vbox(), _vbox = null;
473
473
  watch(table, {
474
474
  find(text) {
475
- $scope.data.searchText = text;
476
- $scope.data.update();
475
+ if ($scope.data.constructor === Table){
476
+ $scope.data.searchText = text;
477
+ $scope.data.update();
478
+ }
477
479
  }
478
480
  })
479
481
  thead = null;
@@ -1,96 +1,221 @@
1
- var transitionKey = 'transition';
2
- var bodyStyle = document.documentElement.style;
3
- if (!(transitionKey in bodyStyle)) {
4
- if ('mozTransition' in bodyStyle) transitionKey = 'mozTransition';
5
- else if ('webkitTransition' in bodyStyle) {
6
- transitionKey = 'webkitTransition';
7
- }
8
- else if ('msTransition' in bodyStyle) {
9
- transitionKey = 'msTransition';
10
- } else {
11
- transitionKey = '';
1
+ function 颜色帧(c1, c2, point) {
2
+ c1 = color.parse(c1);
3
+ c2 = color.parse(c2);
4
+ var hsl1 = color.rgb2hsl(c1);
5
+ var hsl2 = color.rgb2hsl(c2);
6
+ var h = 浮点帧(hsl1[0], hsl2[0], point);
7
+ var s = 浮点帧(hsl1[1], hsl2[1], point);
8
+ var l = 浮点帧(hsl1[2], hsl2[2], point);
9
+ var rgb = color.hsl2rgb([h, s, l]);
10
+ if (c1.length > 3) {
11
+ var a = 浮点帧(c1[3], c2[3], point);
12
+ rgb.push(a);
12
13
  }
14
+ return color.stringify(rgb);
13
15
  }
14
- function transition(target, isLeave, _initialStyle = target.initialStyle || target.enterStyle || target.leavingStyle || target.leaveStyle) {
15
- if (!target) return;
16
- if (typeof isLeave === "string") {
17
- isLeave = parseKV(isLeave, ';', ":");
16
+ function 浮点帧(f1, f2, point) {
17
+ return f1 * point + f2 * (1 - point);
18
+ }
19
+ function 参数帧(a1, a2, point) {
20
+ return a1.map((a, i) => {
21
+ return 单位帧(a.trim(), (a2[i] || '0').trim(), point);
22
+ });
23
+ }
24
+ function 函数帧(p1, p2, point) {
25
+ var r = /([^\(\)]+?)\(([^\)]*)\)/g;
26
+ var o2 = Object.create(null);
27
+ p2.replace(r, function (_, n, p) {
28
+ o2[n] = p;
29
+ });
30
+ return p1.replace(r, function (_, n, p) {
31
+ var v = o2[n];
32
+ if (!v) {
33
+ switch (n) {
34
+ case 'translate':
35
+ v = '0,0';
36
+ break;
37
+ case "scale":
38
+ v = '1,1';
39
+ break;
40
+ default:
41
+ v = '1,0,0,0,1,0';
42
+ }
43
+ }
44
+ return `${n}(${参数帧(p.split(','), v.split(','), point).join(',')})`;
45
+ });
46
+ }
47
+ var targetWidth = innerWidth;
48
+ var unitFloatReg = /^(\d+(?:\.\d+)?|\.\d+)([^\d]*)$/;
49
+ function 单位帧(u1, u2, point) {
50
+ var m1 = unitFloatReg.exec(u1);
51
+ if (!m1) return u1;
52
+ var [, v1, p1] = m1;
53
+ var m2 = unitFloatReg.exec(u2);
54
+ if (m2) {
55
+ if (m1[1] === m2[1]) return 浮点帧(m1[0], m2[2], point) + m1[1];
56
+ var [, v2, p2] = m2;
57
+ if (p2 === "%") {
58
+ v2 = targetWidth * v2;
59
+ }
60
+ if (p1 === "%") {
61
+ v2 = v2 / targetWidth;
62
+ }
18
63
  }
19
- if (isObject(isLeave) && (_initialStyle === true || !_initialStyle)) {
20
- var temp = _initialStyle;
21
- _initialStyle = isLeave;
22
- isLeave = temp;
64
+ else v2 = 0;
65
+ return 浮点帧(v1, v2, point) + p1;
66
+ }
67
+ function 值帧(k, v1, v2, point) {
68
+ if (/color|background/.test(k)) {
69
+ return 颜色帧(v1, v2, point);
23
70
  }
24
- if (isLeave) {
25
- _initialStyle = target.leavingStyle || target.leaveStyle || _initialStyle;
71
+ if (/\(/.test(v1)) {
72
+ return 函数帧(v1, v2, point);
73
+ }
74
+ else {
75
+ v1 = v1.trim().split(/\s+/);
76
+ v2 = v2.trim().split(/\s+/);
77
+ if (v2.length < v1.length) {
78
+ switch (v2.length) {
79
+ case 1:
80
+ v2[1] = v1[0];
81
+ case 2:
82
+ v2[2] = v1[0];
83
+ case 3:
84
+ v2[3] = v1[1];
85
+ }
86
+ }
87
+ return 参数帧(v1, v2, point).join(' ');
88
+ }
89
+ }
90
+ function 帧样式(style, captureStyle, point) {
91
+ var newStyle = new InnerStyle;
92
+ for (var k in style) {
93
+ newStyle[k] = 值帧(k, style[k], captureStyle[k], point);
94
+ }
95
+ return newStyle;
96
+ }
97
+ function InnerStyle(o) {
98
+ for (var k in o) {
99
+ var v = o[k];
100
+ this[css.transformNodeKey(k)] = css.transformValue(v);
101
+ }
102
+ }
103
+
104
+ var transitionKey = css.transformNodeKey("transition");
105
+
106
+ function transition(target, _isLeave, _initialStyle) {
107
+ if (!target) return;
108
+ if ((isObject(isLeave) || typeof isLeave === "string") && (isFinite(_initialStyle) || !_initialStyle)) {
109
+ var temp = _initialStyle;
110
+ _initialStyle = _isLeave;
111
+ _isLeave = temp;
26
112
  }
27
113
  if (target instanceof Array) {
28
114
  target.forEach(function (target) {
29
- transition(target, isLeave, _initialStyle);
115
+ transition(target, _isLeave, _initialStyle);
30
116
  });
31
117
  return;
32
118
  }
33
119
  if (!target.style) return;
34
- var initialStyle = _initialStyle || target.initialStyle;
35
- var { recoverStyle, transitionTimerStart, transitionTimerEnd } = target;
120
+ var isLeave = _isLeave;
121
+ var point = null;
122
+ if (isNumber(isLeave)) {
123
+ point = isLeave;
124
+ }
125
+ var hasInitialStyle = !!_initialStyle;
126
+ if (!_initialStyle) {
127
+ _initialStyle = target.initialStyle || target.enterStyle || target.leavingStyle || target.leaveStyle;
128
+ if (isLeave) {
129
+ _initialStyle = target.leavingStyle || target.leaveStyle || _initialStyle;
130
+ }
131
+ }
132
+ var initialStyle = _initialStyle;
133
+ if (typeof initialStyle === "string") {
134
+ initialStyle = parseKV(initialStyle, ';', ":");
135
+ }
136
+ if (!(initialStyle instanceof InnerStyle)) initialStyle = new InnerStyle(initialStyle);
137
+ if (hasInitialStyle) _initialStyle = initialStyle;
138
+ var { recoverStyle, transitionTimerStart, transitionTimerEnd, captureStyle } = target;
36
139
  clearTimeout(transitionTimerStart);
37
140
  clearTimeout(transitionTimerEnd);
38
141
  if (isString(initialStyle)) {
39
142
  initialStyle = parseKV(initialStyle, ";", ":");
40
143
  }
41
- if (isObject(initialStyle)) {
42
- var transitionDuration = 100;
43
- if (!initialStyle.transition) {
44
- initialStyle.transition = "all .3s ease";
45
- }
46
- if (transitionKey.length > 10) initialStyle[transitionKey] = initialStyle.transition;
47
- String(initialStyle.transition).replace(/([\.\d]+)(m?)s/gi, function (m, d, t) {
48
- if (t) transitionDuration = Math.max(+d, transitionDuration);
49
- else transitionDuration = Math.max(d * 1000, transitionDuration);
50
- return m;
51
- });
52
- transitionDuration = transitionKey ? transitionDuration || 260 : 0;
53
- if (!recoverStyle) {
54
- recoverStyle = {};
144
+ var transitionDuration = 100;
145
+ if (!initialStyle[transitionKey]) {
146
+ initialStyle[transitionKey] = "all .3s ease";
147
+ transitionDuration = 300;
148
+ }
149
+ String(initialStyle[transitionKey]).replace(/([\.\d]+)(m?)s/gi, function (m, d, t) {
150
+ if (t) transitionDuration = Math.max(+d, transitionDuration);
151
+ else transitionDuration = Math.max(d * 1000, transitionDuration);
152
+ return m;
153
+ });
154
+ transitionDuration = transitionDuration || 260;
155
+ if (!recoverStyle) recoverStyle = {};
156
+ if (!captureStyle) captureStyle = {};
157
+ var savedStyle = Object.create(null);
158
+ {
159
+ let originalStyle = target.style;
160
+ for (let k in initialStyle) {
161
+ savedStyle[k] = originalStyle[k];
55
162
  }
56
- var savedStyle = Object.create(null);
57
- {
58
- let originalStyle = target.style;
59
- for (let k in initialStyle) {
60
- savedStyle[k] = originalStyle[k];
61
- }
163
+ let computedStyle = getComputedStyle(target);
164
+ for (let k in initialStyle) {
165
+ if (!(k in captureStyle)) captureStyle[k] = computedStyle[k];
62
166
  }
63
- extendIfNeeded(recoverStyle, savedStyle);
64
- if (isLeave) {
65
- transitionTimerStart = setTimeout(function () {
66
- extend(target.style, initialStyle);
67
- });
68
- transitionTimerEnd = setTimeout(function () {
69
- if (transitionKey) target.style[transitionKey] = recoverStyle.transition;
70
- }, transitionDuration + 2);
71
- } else {
167
+ }
168
+ extendIfNeeded(recoverStyle, savedStyle);
169
+ if (point === 0 || point === 1) {
170
+ isLeave = point === 1;
171
+ point = null;
172
+ var transitionValue = initialStyle[transitionKey];
173
+ delete initialStyle[transitionKey];
174
+ initialStyle = 帧样式(initialStyle, captureStyle, point);
175
+ initialStyle[transitionKey] = transitionValue;
176
+ }
177
+ if (point !== null) {
178
+ delete initialStyle[transitionKey];
179
+ target.style[transitionKey] = 'none';
180
+ initialStyle = 帧样式(initialStyle, captureStyle, point);
181
+ extend(target.style, initialStyle);
182
+ }
183
+ else if (isLeave) {
184
+ transitionTimerStart = setTimeout(function () {
72
185
  extend(target.style, initialStyle);
73
- if (transitionKey) target.style[transitionKey] = "none";
74
- var waitPaint = 20;
75
- transitionTimerStart = setTimeout(function () {
76
- delete recoverStyle.transition;
77
- if (transitionKey) target.style[transitionKey] = initialStyle.transition;
78
- target.transitionTimerStart = setTimeout(function () {
79
- extend(target.style, recoverStyle);
80
- }, waitPaint);
81
- });
82
- transitionTimerEnd = setTimeout(function (transition) {
83
- return function () {
84
- if (transitionKey) target.style[transitionKey] = transition;
85
- };
86
- }(recoverStyle.transition || ''), transitionDuration + waitPaint);
87
- }
88
- target.transitionTimerStart = transitionTimerStart;
89
- target.transitionTimerEnd = transitionTimerEnd;
90
- target.recoverStyle = recoverStyle;
91
- if (target.with) {
92
- transition(target.with, isLeave, _initialStyle);
93
- }
94
- return transitionDuration;
186
+ delete target.recoverStyle;
187
+ delete target.captureStyle;
188
+ });
189
+ transitionTimerEnd = setTimeout(function () {
190
+ if (transitionKey) target.style[transitionKey] = recoverStyle[transitionKey];
191
+ extend(target.style, recoverStyle);
192
+ }, transitionDuration + 2);
193
+ } else {
194
+ extend(target.style, initialStyle);
195
+ if (transitionKey) target.style[transitionKey] = "none";
196
+ var waitPaint = 20;
197
+ transitionTimerStart = setTimeout(function () {
198
+ delete recoverStyle[transitionKey];
199
+ if (transitionKey) target.style[transitionKey] = initialStyle[transitionKey];
200
+ target.transitionTimerStart = setTimeout(function () {
201
+ extend(target.style, recoverStyle);
202
+ delete target.recoverStyle;
203
+ delete target.captureStyle;
204
+ }, waitPaint);
205
+ });
206
+ transitionTimerEnd = setTimeout(function (transition) {
207
+ return function () {
208
+ if (transitionKey) target.style[transitionKey] = transition;
209
+ };
210
+ }(recoverStyle[transitionKey] || ''), transitionDuration + waitPaint);
211
+ }
212
+ target.transitionTimerStart = transitionTimerStart;
213
+ target.transitionTimerEnd = transitionTimerEnd;
214
+ target.recoverStyle = recoverStyle;
215
+ target.captureStyle = captureStyle;
216
+ if (target.with) {
217
+ transition(target.with, _isLeave, _initialStyle);
95
218
  }
219
+ return transitionDuration;
96
220
  }
221
+
@@ -620,9 +620,9 @@ function addGlobal(element, name = null, isDestroy) {
620
620
  if (isFunction(body.layer)) {
621
621
  body.layer(element, oldElement, history);
622
622
  } else {
623
+ if (isDestroy || !oldElement) appendChild.insert(body, element);
624
+ else appendChild.after(oldElement, element);
623
625
  remove(oldElement);
624
- if (isDestroy) appendChild.insert(body, element);
625
- else appendChild(body, element);
626
626
  }
627
627
  global[name] = element;
628
628
  } else if (isNode(name)) {
@@ -704,4 +704,61 @@ zimoli.getCurrentHistory = function () {
704
704
  return history[current_history];
705
705
  };
706
706
  zimoli.inithash = locationInitHash;
707
- zimoli.createState = createState;
707
+ zimoli.createState = createState;
708
+ zimoli.enableTouchBack = function () {
709
+ var touchTarget, currentTarget, history_name, historyList;
710
+ var touchId = 0;
711
+ var ratio = 0;
712
+ var deltaX = 0;
713
+ bindtouch(body, {
714
+ start(event) {
715
+ event.preventDefault();
716
+ ratio = null;
717
+ },
718
+ move(a, event) {
719
+ event.preventDefault();
720
+ if (a !== null) {
721
+ if (!currentTarget) {
722
+ var id = ++touchId;
723
+ history_name = current_history;
724
+ historyList = history[history_name];
725
+ if (historyList.length < 2) return;
726
+ var path1 = historyList[historyList.length - 1];
727
+ var path0 = historyList[historyList.length - 2];
728
+ currentTarget = global[history_name];
729
+ prepare(path0, function () {
730
+ if (id !== touchId) return;
731
+ var args = getZimoliParams(path0).data;
732
+ touchTarget = create(path0, args, path1);
733
+ setWithStyle(touchTarget, true);
734
+ appendChild.insert(body, touchTarget);
735
+ });
736
+ }
737
+ ratio = a.x / body.clientWidth;
738
+ if (ratio <= 0) ratio = 0.001;
739
+ if (ratio >= 1) ratio = 0.999;
740
+ deltaX = a.deltax;
741
+ transition(currentTarget, ratio);
742
+ transition(touchTarget, ratio - 1);
743
+ }
744
+ return { x: ratio * body.clientWidth };
745
+ },
746
+ end() {
747
+ if (ratio === null || !touchTarget) return;
748
+ if (deltaX > 0 && ratio > .1 || deltaX < 0 && ratio > .9 || deltaX === 0 && ratio > .4) {
749
+ pushstate(historyList[historyList.length - 2]);
750
+ remove(currentTarget);
751
+ transition(touchTarget, 1);
752
+ global[history_name] = touchTarget;
753
+ }
754
+ else {
755
+ setWithStyle(touchTarget, false);
756
+ remove(touchTarget);
757
+ transition(currentTarget, 1);
758
+ }
759
+ currentTarget = null;
760
+ touchTarget = null;
761
+ ratio = null;
762
+ }
763
+ }, 'x')
764
+ };