clickgo 3.1.2-dev11 → 3.1.3-dev12

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 (103) hide show
  1. package/dist/app/demo/app.js +0 -73
  2. package/dist/app/demo/config.json +109 -0
  3. package/dist/app/demo/form/control/button/button.js +12 -11
  4. package/dist/app/demo/form/control/button/button.xml +6 -6
  5. package/dist/app/demo/form/control/check/check.js +14 -10
  6. package/dist/app/demo/form/control/file/file.js +15 -13
  7. package/dist/app/demo/form/control/{overflow/overflow.css → flow/flow.css} +0 -0
  8. package/dist/app/demo/form/control/flow/flow.js +64 -0
  9. package/dist/app/demo/form/control/{overflow/overflow.scss → flow/flow.scss} +0 -0
  10. package/dist/app/demo/form/control/flow/flow.xml +101 -0
  11. package/dist/app/demo/form/control/form/form.js +1 -1
  12. package/dist/app/demo/form/control/form/form.xml +3 -3
  13. package/dist/app/demo/form/control/img/img.xml +2 -2
  14. package/dist/app/demo/form/control/list/list.js +95 -75
  15. package/dist/app/demo/form/control/list/list.xml +15 -11
  16. package/dist/app/demo/form/control/marquee/marquee.js +12 -10
  17. package/dist/app/demo/form/control/menu/menu.js +10 -6
  18. package/dist/app/demo/form/control/monaco/monaco.js +50 -60
  19. package/dist/app/demo/form/control/monaco/monaco.xml +6 -5
  20. package/dist/app/demo/form/control/property/property.js +131 -127
  21. package/dist/app/demo/form/control/radio/radio.js +9 -5
  22. package/dist/app/demo/form/control/scroll/scroll.js +16 -12
  23. package/dist/app/demo/form/control/scroll/scroll.xml +10 -10
  24. package/dist/app/demo/form/control/select/select.js +132 -71
  25. package/dist/app/demo/form/control/select/select.xml +69 -67
  26. package/dist/app/demo/form/control/tab/tab.js +21 -20
  27. package/dist/app/demo/form/control/tab/tab.xml +2 -2
  28. package/dist/app/demo/form/control/text/text.js +53 -45
  29. package/dist/app/demo/form/control/text/text.xml +3 -3
  30. package/dist/app/demo/form/control/{greatview/greatview.css → vflow/vflow.css} +0 -0
  31. package/dist/app/demo/form/control/vflow/vflow.js +79 -0
  32. package/dist/app/demo/form/control/{greatview/greatview.scss → vflow/vflow.scss} +0 -0
  33. package/dist/app/demo/form/control/{greatview/greatview.xml → vflow/vflow.xml} +25 -25
  34. package/dist/app/demo/form/event/form/form.js +58 -56
  35. package/dist/app/demo/form/event/form/form.xml +3 -3
  36. package/dist/app/demo/form/event/screen/screen.js +30 -28
  37. package/dist/app/demo/form/event/screen/screen.xml +2 -2
  38. package/dist/app/demo/form/event/task/task.js +31 -31
  39. package/dist/app/demo/form/event/task/task.xml +3 -3
  40. package/dist/app/demo/form/main.js +161 -5
  41. package/dist/app/demo/form/main.xml +36 -35
  42. package/dist/app/demo/form/method/aform/aform.xml +3 -2
  43. package/dist/app/demo/form/method/core/core.js +11 -8
  44. package/dist/app/demo/form/method/core/core.xml +2 -1
  45. package/dist/app/demo/form/method/dom/dom.js +91 -99
  46. package/dist/app/demo/form/method/dom/dom.xml +6 -7
  47. package/dist/app/demo/form/method/form/form.js +8 -8
  48. package/dist/app/demo/form/method/form/form.xml +4 -4
  49. package/dist/app/demo/form/method/fs/fs.js +34 -33
  50. package/dist/app/demo/form/method/fs/fs.xml +1 -1
  51. package/dist/app/demo/form/method/fs/text.js +12 -12
  52. package/dist/app/demo/form/method/native/native.js +50 -0
  53. package/dist/app/demo/form/method/native/native.xml +12 -0
  54. package/dist/app/demo/form/method/system/system.js +50 -0
  55. package/dist/app/demo/form/method/system/system.xml +11 -0
  56. package/dist/app/demo/form/method/task/task.js +59 -61
  57. package/dist/app/demo/form/method/task/task.xml +4 -6
  58. package/dist/app/demo/form/method/theme/theme.js +14 -14
  59. package/dist/app/demo/form/method/tool/tool.js +29 -28
  60. package/dist/app/demo/form/method/tool/tool.xml +3 -3
  61. package/dist/app/demo/form/method/zip/zip.js +46 -41
  62. package/dist/app/demo/form/method/zip/zip.xml +1 -1
  63. package/dist/app/task/app.js +0 -25
  64. package/dist/app/task/config.json +29 -0
  65. package/dist/app/task/form/bar/bar.js +1 -1
  66. package/dist/app/task/form/bar/bar.xml +1 -1
  67. package/dist/clickgo.js +1 -1
  68. package/dist/clickgo.ts +1 -1
  69. package/dist/control/common.cgc +0 -0
  70. package/dist/control/form.cgc +0 -0
  71. package/dist/control/monaco.cgc +0 -0
  72. package/dist/control/property.cgc +0 -0
  73. package/dist/control/task.cgc +0 -0
  74. package/dist/global.css +1 -1
  75. package/dist/index.js +3 -3
  76. package/dist/index.ts +3 -3
  77. package/dist/lib/control.js +70 -104
  78. package/dist/lib/control.ts +97 -123
  79. package/dist/lib/core.js +108 -252
  80. package/dist/lib/core.ts +122 -268
  81. package/dist/lib/dom.js +564 -483
  82. package/dist/lib/dom.ts +703 -546
  83. package/dist/lib/form.js +146 -138
  84. package/dist/lib/form.ts +108 -86
  85. package/dist/lib/fs.js +1 -1
  86. package/dist/lib/fs.ts +1 -1
  87. package/dist/lib/native.js +135 -8
  88. package/dist/lib/native.ts +175 -11
  89. package/dist/lib/task.js +294 -158
  90. package/dist/lib/task.ts +326 -172
  91. package/dist/lib/tool.js +48 -1
  92. package/dist/lib/tool.ts +61 -0
  93. package/dist/lib/zip.ts +2 -0
  94. package/dist/theme/familiar.cgt +0 -0
  95. package/package.json +1 -1
  96. package/types/index.d.ts +23 -24
  97. package/dist/app/demo/form/control/greatview/greatview.js +0 -92
  98. package/dist/app/demo/form/control/overflow/overflow.js +0 -70
  99. package/dist/app/demo/form/control/overflow/overflow.xml +0 -98
  100. package/dist/app/demo/form/control/view/view.css +0 -1
  101. package/dist/app/demo/form/control/view/view.js +0 -73
  102. package/dist/app/demo/form/control/view/view.scss +0 -18
  103. package/dist/app/demo/form/control/view/view.xml +0 -94
package/dist/lib/dom.js CHANGED
@@ -1,9 +1,19 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fullscreen = exports.siblingsData = exports.siblings = exports.findParentByClass = exports.findParentByData = exports.bindResize = exports.bindMove = exports.is = exports.bindDrag = exports.bindLong = exports.allowEvent = exports.bindGesture = exports.bindDown = exports.isWatchStyle = exports.watchStyle = exports.clearWatch = exports.unwatch = exports.watch = exports.clearWatchSize = exports.unwatchSize = exports.watchSize = exports.getSize = exports.getStyleCount = exports.removeStyle = exports.pushStyle = exports.removeFromStyleList = exports.createToStyleList = exports.hasTouchButMouse = exports.setGlobalCursor = void 0;
12
+ exports.fullscreen = exports.siblingsData = exports.siblings = exports.findParentByClass = exports.findParentByData = exports.bindResize = exports.bindMove = exports.is = exports.bindDrag = exports.bindLong = exports.allowEvent = exports.bindGesture = exports.bindDown = exports.bindClick = exports.clearWatchProperty = exports.isWatchProperty = exports.watchProperty = exports.clearWatchStyle = exports.isWatchStyle = exports.watchStyle = exports.clearWatch = exports.isWatch = exports.unwatch = exports.watch = exports.clearWatchSize = exports.isWatchSize = exports.unwatchSize = exports.watchSize = exports.getStyleCount = exports.removeStyle = exports.pushStyle = exports.removeFromStyleList = exports.createToStyleList = exports.hasTouchButMouse = exports.setGlobalCursor = void 0;
4
13
  const clickgo = require("../clickgo");
5
14
  const form = require("./form");
6
15
  const core = require("./core");
16
+ const tool = require("./tool");
7
17
  const topClass = ['#cg-form-list', '#cg-pop-list', '#cg-system', '#cg-simpletask', '#cg-launcher'];
8
18
  function classUnfold(after, out = []) {
9
19
  const arr = [];
@@ -20,8 +30,8 @@ styleList.style.display = 'none';
20
30
  document.getElementsByTagName('body')[0].appendChild(styleList);
21
31
  styleList.insertAdjacentHTML('beforeend', '<style id=\'cg-global-cursor\'></style>');
22
32
  styleList.insertAdjacentHTML('beforeend', `<style id='cg-global'>
23
- ${classUnfold()} {-webkit-user-select: none; user-select: none; position: fixed; cursor: default; box-sizing: border-box;}
24
- ${topClass.slice(0, 3).join(', ')} {left: 0; top: 0; width: 0; height: 0;}
33
+ ${classUnfold()} {-webkit-user-select: none; user-select: none; cursor: default; box-sizing: border-box;}
34
+ ${topClass.slice(0, 3).join(', ')} {left: 0; top: 0; width: 0; height: 0; position: absolute;}
25
35
  ${classUnfold('img')} {vertical-align: bottom;}
26
36
  ${classUnfold('::selection', ['#cg-launcher'])} {background-color: rgba(0, 0, 0, .1);}
27
37
  ${classUnfold('*')}, ${classUnfold('*::after')}, ${classUnfold('*::before')} {box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); flex-shrink: 0;}
@@ -125,127 +135,110 @@ function getStyleCount(taskId, type) {
125
135
  return document.querySelectorAll(`#cg-style-task${taskId} > .cg-style-${type} > style`).length;
126
136
  }
127
137
  exports.getStyleCount = getStyleCount;
128
- function getSize(el) {
129
- const rect = el.getBoundingClientRect();
130
- const cs = getComputedStyle(el);
131
- const border = {
132
- 'top': parseFloat(cs.borderTopWidth),
133
- 'right': parseFloat(cs.borderRightWidth),
134
- 'bottom': parseFloat(cs.borderBottomWidth),
135
- 'left': parseFloat(cs.borderLeftWidth)
136
- };
137
- const padding = {
138
- 'top': parseFloat(cs.paddingTop),
139
- 'right': parseFloat(cs.paddingRight),
140
- 'bottom': parseFloat(cs.paddingBottom),
141
- 'left': parseFloat(cs.paddingLeft)
142
- };
143
- return {
144
- 'top': rect.top,
145
- 'right': rect.right,
146
- 'bottom': rect.bottom,
147
- 'left': rect.left,
148
- 'width': rect.width,
149
- 'height': rect.height,
150
- 'padding': padding,
151
- 'border': border,
152
- 'clientWidth': rect.width - border.left - border.right,
153
- 'clientHeight': rect.height - border.top - border.bottom,
154
- 'innerWidth': rect.width - border.left - border.right - padding.left - padding.right,
155
- 'innerHeight': rect.height - border.top - border.bottom - padding.top - padding.bottom,
156
- 'scrollWidth': el.scrollWidth,
157
- 'scrollHeight': el.scrollHeight
158
- };
159
- }
160
- exports.getSize = getSize;
161
- const watchSizeList = [];
162
- function watchSize(el, cb, immediate = false, taskId) {
163
- const fsize = getSize(el);
164
- for (const item of watchSizeList) {
165
- if (item.el === el) {
166
- return fsize;
138
+ const watchSizeList = {};
139
+ let watchSizeIndex = 0;
140
+ const resizeObserver = new ResizeObserver(function (entries) {
141
+ for (const entrie of entries) {
142
+ const el = entrie.target;
143
+ if (!el.offsetParent) {
144
+ resizeObserver.unobserve(el);
145
+ if (watchSizeList[el.dataset.cgRoindex]) {
146
+ delete watchSizeList[el.dataset.cgRoindex];
147
+ }
148
+ continue;
167
149
  }
168
- }
169
- if (immediate) {
170
- const r = cb(fsize);
171
- if (r instanceof Promise) {
172
- r.catch(function (e) {
173
- console.log(e);
174
- });
150
+ const item = watchSizeList[el.dataset.cgRoindex];
151
+ try {
152
+ const r = item.handler();
153
+ if (r instanceof Promise) {
154
+ r.catch(function (e) {
155
+ console.log('ResizeObserver', e);
156
+ });
157
+ }
158
+ }
159
+ catch (e) {
160
+ console.log('ResizeObserver', e);
175
161
  }
176
162
  }
177
- const resizeObserver = new window.ResizeObserver(function () {
178
- const size = getSize(el);
179
- if (Number.isNaN(size.clientWidth)) {
180
- return;
163
+ });
164
+ function watchSize(el, cb, immediate = false, taskId) {
165
+ if (isWatchSize(el)) {
166
+ return false;
167
+ }
168
+ if (immediate) {
169
+ try {
170
+ const r = cb();
171
+ if (r instanceof Promise) {
172
+ r.catch(function (e) {
173
+ console.log('dom.watchSize', e);
174
+ });
175
+ }
181
176
  }
182
- const r = cb(size);
183
- if (r instanceof Promise) {
184
- r.catch(function (e) {
185
- console.log(e);
186
- });
177
+ catch (e) {
178
+ console.log('dom.watchSize', e);
187
179
  }
188
- });
180
+ }
189
181
  resizeObserver.observe(el);
190
- watchSizeList.push({
182
+ watchSizeList[watchSizeIndex] = {
191
183
  'el': el,
192
- 'ro': resizeObserver,
184
+ 'handler': cb,
193
185
  'taskId': taskId
194
- });
195
- return fsize;
186
+ };
187
+ el.dataset.cgRoindex = watchSizeIndex.toString();
188
+ ++watchSizeIndex;
189
+ return true;
196
190
  }
197
191
  exports.watchSize = watchSize;
198
192
  function unwatchSize(el, taskId) {
199
- for (let i = 0; i < watchSizeList.length; ++i) {
200
- const item = watchSizeList[i];
201
- if (item.el !== el) {
202
- continue;
203
- }
204
- if (taskId && taskId !== item.taskId) {
205
- return;
206
- }
207
- if (item.el.offsetParent) {
208
- item.ro.unobserve(item.el);
209
- }
210
- watchSizeList.splice(i, 1);
211
- --i;
193
+ const index = el.dataset.cgRoindex;
194
+ if (index === undefined) {
195
+ return;
196
+ }
197
+ const item = watchSizeList[index];
198
+ if (taskId && item.taskId !== taskId) {
212
199
  return;
213
200
  }
201
+ resizeObserver.unobserve(el);
202
+ el.removeAttribute('data-cg-roindex');
203
+ delete watchSizeList[index];
214
204
  }
215
205
  exports.unwatchSize = unwatchSize;
206
+ function isWatchSize(el) {
207
+ return el.dataset.cgRoindex ? true : false;
208
+ }
209
+ exports.isWatchSize = isWatchSize;
216
210
  function clearWatchSize(taskId) {
217
- if (!taskId) {
218
- return;
219
- }
220
- for (let i = 0; i < watchSizeList.length; ++i) {
221
- const item = watchSizeList[i];
211
+ for (const index in watchSizeList) {
212
+ const item = watchSizeList[index];
222
213
  if (taskId !== item.taskId) {
223
214
  continue;
224
215
  }
225
- if (item.el.offsetParent) {
226
- item.ro.unobserve(item.el);
227
- }
228
- watchSizeList.splice(i, 1);
229
- --i;
216
+ resizeObserver.unobserve(item.el);
217
+ item.el.removeAttribute('data-cg-roindex');
218
+ delete watchSizeList[index];
230
219
  }
231
220
  }
232
221
  exports.clearWatchSize = clearWatchSize;
233
- function cgClearWatchSize() {
234
- for (let i = 0; i < watchSizeList.length; ++i) {
235
- const item = watchSizeList[i];
236
- if (item.el.offsetParent) {
237
- continue;
238
- }
239
- watchSizeList.splice(i, 1);
240
- --i;
241
- }
242
- }
243
- setInterval(cgClearWatchSize, 1000 * 60 * 5);
244
- const watchList = [];
222
+ const watchList = {};
223
+ let watchIndex = 0;
245
224
  function watch(el, cb, mode = 'default', immediate = false, taskId) {
225
+ if (isWatch(el)) {
226
+ return false;
227
+ }
246
228
  if (immediate) {
247
- cb();
229
+ try {
230
+ const r = cb([]);
231
+ if (r instanceof Promise) {
232
+ r.catch(function (e) {
233
+ console.log('dom.watch', e);
234
+ });
235
+ }
236
+ }
237
+ catch (e) {
238
+ console.log('dom.watch', e);
239
+ }
248
240
  }
241
+ const index = watchIndex;
249
242
  let moi;
250
243
  switch (mode) {
251
244
  case 'child': {
@@ -284,74 +277,88 @@ function watch(el, cb, mode = 'default', immediate = false, taskId) {
284
277
  moi = mode;
285
278
  }
286
279
  }
287
- const mo = new MutationObserver(cb);
280
+ const mo = new MutationObserver((mutations) => {
281
+ if (!el.offsetParent) {
282
+ mo.disconnect();
283
+ if (watchList[index]) {
284
+ delete watchList[index];
285
+ }
286
+ return;
287
+ }
288
+ try {
289
+ const r = cb(mutations);
290
+ if (r instanceof Promise) {
291
+ r.catch(function (e) {
292
+ console.log('dom.watch', e);
293
+ });
294
+ }
295
+ }
296
+ catch (e) {
297
+ console.log('dom.watch', e);
298
+ }
299
+ });
288
300
  mo.observe(el, moi);
289
- watchList.push({
301
+ watchList[index] = {
290
302
  'el': el,
291
303
  'mo': mo,
292
304
  'taskId': taskId
293
- });
305
+ };
306
+ el.dataset.cgMoindex = index.toString();
307
+ ++watchIndex;
308
+ return true;
294
309
  }
295
310
  exports.watch = watch;
296
311
  function unwatch(el, taskId) {
297
- for (let i = 0; i < watchList.length; ++i) {
298
- const item = watchList[i];
299
- if (item.el !== el) {
300
- continue;
301
- }
302
- if (taskId && taskId !== item.taskId) {
303
- return;
304
- }
305
- if (item.el.offsetParent) {
306
- item.mo.disconnect();
307
- }
308
- watchList.splice(i, 1);
309
- --i;
312
+ const index = el.dataset.cgMoindex;
313
+ if (index === undefined) {
310
314
  return;
311
315
  }
316
+ const item = watchList[index];
317
+ if (taskId && item.taskId !== taskId) {
318
+ return;
319
+ }
320
+ el.removeAttribute('data-cg-moindex');
321
+ watchList[index].mo.disconnect();
322
+ delete watchList[index];
312
323
  }
313
324
  exports.unwatch = unwatch;
325
+ function isWatch(el) {
326
+ return el.dataset.cgMoindex ? true : false;
327
+ }
328
+ exports.isWatch = isWatch;
314
329
  function clearWatch(taskId) {
315
- if (!taskId) {
316
- return;
317
- }
318
- for (let i = 0; i < watchList.length; ++i) {
319
- const item = watchList[i];
330
+ for (const index in watchList) {
331
+ const item = watchList[index];
320
332
  if (taskId !== item.taskId) {
321
333
  continue;
322
334
  }
323
- if (item.el.offsetParent) {
324
- item.mo.disconnect();
325
- }
326
- watchList.splice(i, 1);
327
- --i;
335
+ item.el.removeAttribute('data-cg-moindex');
336
+ item.mo.disconnect();
337
+ delete watchList[index];
328
338
  }
329
339
  }
330
340
  exports.clearWatch = clearWatch;
331
- function cgClearWatch() {
332
- for (let i = 0; i < watchList.length; ++i) {
333
- const item = watchList[i];
334
- if (item.el.offsetParent) {
335
- continue;
336
- }
337
- watchList.splice(i, 1);
338
- --i;
339
- }
340
- }
341
- setInterval(cgClearWatch, 1000 * 60 * 5);
342
- const watchStyleObjects = [];
341
+ const watchStyleList = {};
342
+ let watchStyleIndex = 0;
343
343
  function watchStyle(el, name, cb, immediate = false) {
344
344
  if (typeof name === 'string') {
345
345
  name = [name];
346
346
  }
347
- for (const item of watchStyleObjects) {
348
- if (item.el !== el) {
349
- continue;
350
- }
347
+ const formWrap = findParentByData(el, 'form-id');
348
+ if (!formWrap) {
349
+ return;
350
+ }
351
+ const formId = formWrap.dataset.formId;
352
+ if (!watchStyleList[formId]) {
353
+ watchStyleList[formId] = {};
354
+ }
355
+ const index = el.dataset.cgStyleindex;
356
+ if (index) {
357
+ const item = watchStyleList[formId][index];
351
358
  for (const n of name) {
352
359
  if (!item.names[n]) {
353
360
  item.names[n] = {
354
- 'old': item.sd[n],
361
+ 'val': item.sd[n],
355
362
  'cb': [cb]
356
363
  };
357
364
  }
@@ -359,60 +366,185 @@ function watchStyle(el, name, cb, immediate = false) {
359
366
  item.names[n].cb.push(cb);
360
367
  }
361
368
  if (immediate) {
362
- cb(n, item.sd[n]);
369
+ cb(n, item.sd[n], '');
363
370
  }
364
371
  }
365
372
  return;
366
373
  }
367
374
  const sd = getComputedStyle(el);
368
- watchStyleObjects.push({
375
+ watchStyleList[formId][watchStyleIndex] = {
369
376
  'el': el,
370
377
  'sd': sd,
371
378
  'names': {}
372
- });
373
- const item = watchStyleObjects[watchStyleObjects.length - 1];
379
+ };
380
+ const item = watchStyleList[formId][watchStyleIndex];
374
381
  for (const n of name) {
375
382
  item.names[n] = {
376
- 'old': item.sd[n],
383
+ 'val': item.sd[n],
377
384
  'cb': [cb]
378
385
  };
379
386
  if (immediate) {
380
- cb(n, item.sd[n]);
387
+ cb(n, item.sd[n], '');
381
388
  }
382
389
  }
390
+ el.dataset.cgStyleindex = watchStyleIndex.toString();
391
+ ++watchStyleIndex;
383
392
  }
384
393
  exports.watchStyle = watchStyle;
385
- const watchStyleRAF = function () {
386
- for (let i = 0; i < watchStyleObjects.length; ++i) {
387
- const item = watchStyleObjects[i];
388
- if (watchStyleObjects[i].sd.flex === '') {
389
- watchStyleObjects.splice(i, 1);
390
- --i;
391
- continue;
392
- }
393
- for (const name in item.names) {
394
- if (item.sd[name] === item.names[name].old) {
395
- continue;
396
- }
397
- item.names[name].old = item.sd[name];
398
- for (const cb of item.names[name].cb) {
399
- cb(name, item.sd[name]);
394
+ let watchStyleTimer = 0;
395
+ const watchStyleHandler = function () {
396
+ if (form.getFocus) {
397
+ const formId = form.getFocus();
398
+ if (formId && watchStyleList[formId]) {
399
+ for (const index in watchStyleList[formId]) {
400
+ const item = watchStyleList[formId][index];
401
+ if (!item.el.offsetParent) {
402
+ delete watchStyleList[formId][index];
403
+ if (!Object.keys(watchStyleList[formId]).length) {
404
+ delete watchStyleList[formId];
405
+ }
406
+ continue;
407
+ }
408
+ for (const name in item.names) {
409
+ if (item.sd[name] === item.names[name].val) {
410
+ continue;
411
+ }
412
+ const old = item.names[name].val;
413
+ item.names[name].val = item.sd[name];
414
+ for (const cb of item.names[name].cb) {
415
+ cb(name, item.sd[name], old);
416
+ }
417
+ }
400
418
  }
401
419
  }
402
420
  }
403
- requestAnimationFrame(watchStyleRAF);
421
+ watchStyleTimer = requestAnimationFrame(watchStyleHandler);
404
422
  };
405
- watchStyleRAF();
423
+ watchStyleHandler();
406
424
  function isWatchStyle(el) {
407
- for (const item of watchStyleObjects) {
408
- if (item.el !== el) {
409
- continue;
425
+ return el.dataset.cgStyleindex ? true : false;
426
+ }
427
+ exports.isWatchStyle = isWatchStyle;
428
+ function clearWatchStyle(formId) {
429
+ if (!watchStyleList[formId]) {
430
+ return;
431
+ }
432
+ for (const index in watchStyleList[formId]) {
433
+ const item = watchStyleList[formId][index];
434
+ item.el.removeAttribute('data-cg-styleindex');
435
+ }
436
+ delete watchStyleList[formId];
437
+ }
438
+ exports.clearWatchStyle = clearWatchStyle;
439
+ const watchPropertyObjects = {};
440
+ let watchPropertyIndex = 0;
441
+ function watchProperty(el, name, cb, immediate = false) {
442
+ if (typeof name === 'string') {
443
+ name = [name];
444
+ }
445
+ const formWrap = findParentByData(el, 'form-id');
446
+ if (!formWrap) {
447
+ return;
448
+ }
449
+ const formId = formWrap.dataset.formId;
450
+ if (!watchPropertyObjects[formId]) {
451
+ watchPropertyObjects[formId] = {};
452
+ }
453
+ const index = el.dataset.cgPropertyindex;
454
+ if (index) {
455
+ const item = watchPropertyObjects[formId][index];
456
+ for (const n of name) {
457
+ if (!item.names[n]) {
458
+ item.names[n] = {
459
+ 'val': item.el[n],
460
+ 'cb': [cb]
461
+ };
462
+ }
463
+ else {
464
+ item.names[n].cb.push(cb);
465
+ }
466
+ if (immediate) {
467
+ cb(n, item.el[n]);
468
+ }
410
469
  }
411
- return true;
470
+ return;
412
471
  }
413
- return false;
472
+ watchPropertyObjects[formId][watchPropertyIndex] = {
473
+ 'el': el,
474
+ 'names': {}
475
+ };
476
+ const item = watchPropertyObjects[formId][watchPropertyIndex];
477
+ for (const n of name) {
478
+ item.names[n] = {
479
+ 'val': item.el[n],
480
+ 'cb': [cb]
481
+ };
482
+ if (immediate) {
483
+ cb(n, item.el[n]);
484
+ }
485
+ }
486
+ el.dataset.cgPropertyindex = watchPropertyIndex.toString();
487
+ ++watchPropertyIndex;
414
488
  }
415
- exports.isWatchStyle = isWatchStyle;
489
+ exports.watchProperty = watchProperty;
490
+ let watchPropertyTimer = 0;
491
+ const watchPropertyHandler = function () {
492
+ if (form.getFocus) {
493
+ const formId = form.getFocus();
494
+ if (formId && watchPropertyObjects[formId]) {
495
+ for (const index in watchPropertyObjects[formId]) {
496
+ const item = watchPropertyObjects[formId][index];
497
+ if (!item.el.offsetParent) {
498
+ delete watchPropertyObjects[formId][index];
499
+ if (!Object.keys(watchPropertyObjects[formId]).length) {
500
+ delete watchPropertyObjects[formId];
501
+ }
502
+ continue;
503
+ }
504
+ for (const name in item.names) {
505
+ if (item.el[name] === item.names[name].val) {
506
+ continue;
507
+ }
508
+ item.names[name].val = item.el[name];
509
+ for (const cb of item.names[name].cb) {
510
+ cb(name, item.el[name]);
511
+ }
512
+ }
513
+ }
514
+ }
515
+ }
516
+ watchPropertyTimer = requestAnimationFrame(watchPropertyHandler);
517
+ };
518
+ watchPropertyHandler();
519
+ function isWatchProperty(el) {
520
+ return el.dataset.cgPropertyindex ? true : false;
521
+ }
522
+ exports.isWatchProperty = isWatchProperty;
523
+ function clearWatchProperty(formId) {
524
+ if (!watchPropertyObjects[formId]) {
525
+ return;
526
+ }
527
+ for (const index in watchPropertyObjects[formId]) {
528
+ const item = watchPropertyObjects[formId][index];
529
+ item.el.removeAttribute('data-cg-propertyindex');
530
+ }
531
+ delete watchPropertyObjects[formId];
532
+ }
533
+ exports.clearWatchProperty = clearWatchProperty;
534
+ function bindClick(e, handler) {
535
+ const x = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
536
+ const y = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
537
+ bindDown(e, {
538
+ up: (ne) => {
539
+ const nx = ne instanceof MouseEvent ? ne.clientX : ne.touches[0].clientX;
540
+ const ny = ne instanceof MouseEvent ? ne.clientY : ne.touches[0].clientY;
541
+ if (nx === x && ny === y) {
542
+ handler();
543
+ }
544
+ }
545
+ });
546
+ }
547
+ exports.bindClick = bindClick;
416
548
  function bindDown(oe, opt) {
417
549
  var _a;
418
550
  if (hasTouchButMouse(oe)) {
@@ -430,7 +562,7 @@ function bindDown(oe, opt) {
430
562
  let isStart = false;
431
563
  let end = undefined;
432
564
  const move = function (e) {
433
- if (!e.target || !e.target.offsetParent) {
565
+ if ((!e.target || !e.target.offsetParent) && e.cancelable) {
434
566
  e.preventDefault();
435
567
  }
436
568
  let dir = 'top';
@@ -523,342 +655,268 @@ function bindDown(oe, opt) {
523
655
  (_a = opt.down) === null || _a === void 0 ? void 0 : _a.call(opt, oe);
524
656
  }
525
657
  exports.bindDown = bindDown;
526
- const bindGestureData = {
527
- 'el': null,
528
- 'xx': 0,
529
- 'xy': 0,
530
- 'tx': 0,
531
- 'ty': 0,
532
- 'dir': null,
533
- 'timers': {
534
- 'ani': 0,
535
- 'sleep': 0
536
- }
658
+ const gestureWheel = {
659
+ 'last': 0,
660
+ 'offset': 0,
661
+ 'done': false,
662
+ 'timer': 0,
663
+ 'firstTimer': false,
664
+ 'dir': ''
537
665
  };
538
- function clearGestureData() {
539
- bindGestureData.xx = 0;
540
- bindGestureData.xy = 0;
541
- bindGestureData.tx = 0;
542
- bindGestureData.ty = 0;
543
- }
544
- function bindGestureAnimation(opt) {
545
- var _a;
546
- if (!bindGestureData.el) {
547
- return;
548
- }
549
- const speed = 6;
550
- const gestureElement = document.getElementById('cg-gesture');
551
- const dirs = (_a = opt.dirs) !== null && _a !== void 0 ? _a : ['top', 'bottom'];
552
- if (bindGestureData.tx > bindGestureData.xx) {
553
- bindGestureData.xx += speed;
554
- if (bindGestureData.xx > bindGestureData.tx) {
555
- bindGestureData.xx = bindGestureData.tx;
556
- }
557
- }
558
- else {
559
- bindGestureData.xx -= speed;
560
- if (bindGestureData.xx < bindGestureData.tx) {
561
- bindGestureData.xx = bindGestureData.tx;
562
- }
563
- }
564
- if (bindGestureData.ty > bindGestureData.xy) {
565
- bindGestureData.xy += speed;
566
- if (bindGestureData.xy > bindGestureData.ty) {
567
- bindGestureData.xy = bindGestureData.ty;
568
- }
569
- }
570
- else {
571
- bindGestureData.xy -= speed;
572
- if (bindGestureData.xy < bindGestureData.ty) {
573
- bindGestureData.xy = bindGestureData.ty;
574
- }
575
- }
576
- const xxAbs = Math.abs(bindGestureData.xx);
577
- const xyAbs = Math.abs(bindGestureData.xy);
578
- if ((!dirs.includes('top') && !dirs.includes('bottom')) || ((xxAbs > xyAbs) && (dirs.includes('left') || dirs.includes('right')))) {
579
- if (bindGestureData.xx < 0) {
580
- if (!dirs.includes('left')) {
581
- gestureElement.style.opacity = '0';
582
- clearGestureData();
583
- return;
584
- }
585
- gestureElement.style.opacity = '1';
586
- if (xxAbs === 90) {
587
- bindGestureData.dir = 'left';
588
- gestureElement.classList.add('done');
589
- }
590
- else {
591
- bindGestureData.dir = null;
592
- gestureElement.classList.remove('done');
593
- }
594
- gestureElement.style.top = (opt.rect.top + ((opt.rect.height - 20) / 2)).toString() + 'px';
595
- gestureElement.style.left = (opt.rect.left - 10 + (xxAbs / 1.5)).toString() + 'px';
596
- gestureElement.style.transform = 'scale(' + (xxAbs / 90).toString() + ')';
597
- }
598
- else {
599
- if (!dirs.includes('right')) {
600
- gestureElement.style.opacity = '0';
601
- clearGestureData();
602
- return;
603
- }
604
- gestureElement.style.opacity = '1';
605
- if (xxAbs === 90) {
606
- bindGestureData.dir = 'right';
607
- gestureElement.classList.add('done');
608
- }
609
- else {
610
- bindGestureData.dir = null;
611
- gestureElement.classList.remove('done');
612
- }
613
- gestureElement.style.top = (opt.rect.top + ((opt.rect.height - 20) / 2)).toString() + 'px';
614
- gestureElement.style.left = (opt.rect.left + opt.rect.width - 10 - (xxAbs / 1.5)).toString() + 'px';
615
- gestureElement.style.transform = 'scale(' + (xxAbs / 90).toString() + ')';
616
- }
617
- }
618
- else {
619
- if (bindGestureData.xy < 0) {
620
- if (!dirs.includes('top')) {
621
- gestureElement.style.opacity = '0';
622
- clearGestureData();
623
- return;
624
- }
625
- gestureElement.style.opacity = '1';
626
- if (xyAbs === 90) {
627
- bindGestureData.dir = 'top';
628
- gestureElement.classList.add('done');
629
- }
630
- else {
631
- bindGestureData.dir = null;
632
- gestureElement.classList.remove('done');
633
- }
634
- gestureElement.style.left = (opt.rect.left + ((opt.rect.width - 20) / 2)).toString() + 'px';
635
- gestureElement.style.top = (opt.rect.top - 10 + (xyAbs / 1.5)).toString() + 'px';
636
- gestureElement.style.transform = 'scale(' + (xyAbs / 90).toString() + ')';
637
- }
638
- else {
639
- if (!dirs.includes('bottom')) {
640
- gestureElement.style.opacity = '0';
641
- clearGestureData();
642
- return;
643
- }
644
- gestureElement.style.opacity = '1';
645
- if (xyAbs === 90) {
646
- bindGestureData.dir = 'bottom';
647
- gestureElement.classList.add('done');
648
- }
649
- else {
650
- bindGestureData.dir = null;
651
- gestureElement.classList.remove('done');
652
- }
653
- gestureElement.style.left = (opt.rect.left + ((opt.rect.width - 20) / 2)).toString() + 'px';
654
- gestureElement.style.top = (opt.rect.top + opt.rect.height - 10 - (xyAbs / 1.5)).toString() + 'px';
655
- gestureElement.style.transform = 'scale(' + (xyAbs / 90).toString() + ')';
656
- }
657
- }
658
- if (bindGestureData.xx === bindGestureData.tx && bindGestureData.xy === bindGestureData.ty) {
659
- bindGestureData.timers.ani = 0;
660
- bindGestureData.timers.sleep = window.setTimeout(() => {
661
- clearGestureData();
662
- bindGestureData.timers.sleep = 0;
663
- gestureElement.style.opacity = '0';
664
- if (!bindGestureData.dir) {
665
- return;
666
- }
667
- opt.handler(bindGestureData.dir);
668
- }, 500);
669
- return;
670
- }
671
- bindGestureData.timers.ani = requestAnimationFrame(() => {
672
- bindGestureAnimation(opt);
673
- });
674
- }
675
- function bindGesture(e, opt) {
676
- var _a, _b, _c, _d, _e;
677
- const gestureElement = document.getElementById('cg-gesture');
678
- const el = (_b = (_a = e.currentTarget) !== null && _a !== void 0 ? _a : e.target) !== null && _b !== void 0 ? _b : opt.el;
666
+ function bindGesture(oe, before, handler) {
667
+ const el = oe.currentTarget;
679
668
  if (!el) {
680
669
  return;
681
670
  }
682
- let rect;
683
- if (e.rect) {
684
- rect = e.rect;
685
- }
686
- else if (opt.rect) {
687
- rect = opt.rect;
688
- }
689
- else {
690
- if (!(el.getBoundingClientRect)) {
691
- return;
692
- }
693
- rect = el.getBoundingClientRect();
694
- }
695
- const dirs = (_c = opt.dirs) !== null && _c !== void 0 ? _c : ['top', 'bottom'];
696
- if ((e instanceof MouseEvent || e instanceof TouchEvent) && !(e instanceof WheelEvent)) {
697
- const x = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
698
- const y = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
699
- let dir = null;
700
- bindDown(e, {
701
- move: (e) => {
702
- e.preventDefault();
703
- if (bindGestureData.timers.ani !== 0) {
704
- cancelAnimationFrame(bindGestureData.timers.ani);
705
- bindGestureData.timers.ani = 0;
706
- }
707
- if (bindGestureData.timers.sleep !== 0) {
708
- clearTimeout(bindGestureData.timers.sleep);
709
- bindGestureData.timers.sleep = 0;
671
+ const rect = el.getBoundingClientRect();
672
+ if ((oe instanceof MouseEvent || oe instanceof TouchEvent) && !(oe instanceof WheelEvent)) {
673
+ let offset = 0;
674
+ let origin = 0;
675
+ let first = 1;
676
+ let dir = 'top';
677
+ bindDown(oe, {
678
+ move: (e, d) => {
679
+ if (first < 0) {
680
+ if (first > -30) {
681
+ before(e, dir);
682
+ --first;
683
+ }
684
+ return;
710
685
  }
711
- const nx = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
712
- const ny = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
713
- const xx = nx - x;
714
- const xy = ny - y;
715
- let xxAbs = Math.abs(xx);
716
- let xyAbs = Math.abs(xy);
717
- if ((!dirs.includes('top') && !dirs.includes('bottom')) || ((xxAbs > xyAbs) && (dirs.includes('left') || dirs.includes('right')))) {
718
- if (xx > 0) {
719
- if (!dirs.includes('left')) {
720
- gestureElement.style.opacity = '0';
721
- return;
686
+ if (first === 1) {
687
+ first = 0;
688
+ switch (d) {
689
+ case 'top': {
690
+ dir = 'bottom';
691
+ break;
722
692
  }
723
- gestureElement.style.opacity = '1';
724
- if (xxAbs > 90) {
725
- xxAbs = 90;
693
+ case 'bottom': {
694
+ dir = 'top';
695
+ break;
696
+ }
697
+ case 'left': {
698
+ dir = 'right';
699
+ break;
700
+ }
701
+ default: {
726
702
  dir = 'left';
727
- gestureElement.classList.add('done');
728
703
  }
729
- else {
730
- dir = null;
731
- gestureElement.classList.remove('done');
704
+ }
705
+ if (!before(e, dir)) {
706
+ first = -1;
707
+ return;
708
+ }
709
+ switch (dir) {
710
+ case 'top':
711
+ case 'bottom': {
712
+ origin = oe instanceof MouseEvent ? oe.clientY : oe.touches[0].clientY;
713
+ break;
714
+ }
715
+ default: {
716
+ origin = oe instanceof MouseEvent ? oe.clientX : oe.touches[0].clientX;
732
717
  }
733
- gestureElement.style.top = (rect.top + ((rect.height - 20) / 2)).toString() + 'px';
734
- gestureElement.style.left = (rect.left - 10 + (xxAbs / 1.5)).toString() + 'px';
735
- gestureElement.style.transform = 'scale(' + (xxAbs / 90).toString() + ')';
736
718
  }
737
- else {
738
- if (!dirs.includes('right')) {
739
- gestureElement.style.opacity = '0';
740
- return;
719
+ }
720
+ let pos = 0;
721
+ switch (dir) {
722
+ case 'top':
723
+ case 'bottom': {
724
+ pos = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
725
+ if (dir === 'top') {
726
+ offset = pos - origin;
741
727
  }
742
- gestureElement.style.opacity = '1';
743
- if (xxAbs > 90) {
744
- xxAbs = 90;
745
- dir = 'right';
746
- gestureElement.classList.add('done');
728
+ else {
729
+ offset = origin - pos;
730
+ }
731
+ break;
732
+ }
733
+ default: {
734
+ pos = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
735
+ if (dir === 'left') {
736
+ offset = pos - origin;
747
737
  }
748
738
  else {
749
- dir = null;
750
- gestureElement.classList.remove('done');
739
+ offset = origin - pos;
751
740
  }
752
- gestureElement.style.top = (rect.top + ((rect.height - 20) / 2)).toString() + 'px';
753
- gestureElement.style.left = (rect.left + rect.width - 10 - (xxAbs / 1.5)).toString() + 'px';
754
- gestureElement.style.transform = 'scale(' + (xxAbs / 90).toString() + ')';
755
741
  }
756
742
  }
743
+ if (offset >= 90) {
744
+ offset = 90;
745
+ form.elements.gesture.style.opacity = '1';
746
+ form.elements.gesture.classList.add('done');
747
+ }
757
748
  else {
758
- if (xy > 0) {
759
- if (!dirs.includes('top')) {
760
- gestureElement.style.opacity = '0';
761
- return;
762
- }
763
- gestureElement.style.opacity = '1';
764
- if (xyAbs > 90) {
765
- xyAbs = 90;
766
- dir = 'top';
767
- gestureElement.classList.add('done');
749
+ form.elements.gesture.classList.remove('done');
750
+ if (offset < 0) {
751
+ offset = 0;
752
+ form.elements.gesture.style.opacity = '0';
753
+ }
754
+ else {
755
+ form.elements.gesture.style.opacity = '1';
756
+ }
757
+ }
758
+ form.elements.gesture.style.transform = 'scale(' + (offset / 90).toString() + ')';
759
+ switch (dir) {
760
+ case 'top':
761
+ case 'bottom': {
762
+ form.elements.gesture.style.left = (rect.left + ((rect.width - 20) / 2)).toString() + 'px';
763
+ if (dir === 'top') {
764
+ form.elements.gesture.style.top = (rect.top + (offset / 1.5)).toString() + 'px';
768
765
  }
769
766
  else {
770
- dir = null;
771
- gestureElement.classList.remove('done');
767
+ form.elements.gesture.style.top = (rect.bottom - 20 - (offset / 1.5)).toString() + 'px';
772
768
  }
773
- gestureElement.style.left = (rect.left + ((rect.width - 20) / 2)).toString() + 'px';
774
- gestureElement.style.top = (rect.top - 10 + (xyAbs / 1.5)).toString() + 'px';
775
- gestureElement.style.transform = 'scale(' + (xyAbs / 90).toString() + ')';
769
+ break;
776
770
  }
777
- else {
778
- if (!dirs.includes('bottom')) {
779
- gestureElement.style.opacity = '0';
780
- return;
781
- }
782
- gestureElement.style.opacity = '1';
783
- if (xyAbs > 90) {
784
- xyAbs = 90;
785
- dir = 'bottom';
786
- gestureElement.classList.add('done');
771
+ default: {
772
+ form.elements.gesture.style.top = (rect.top + ((rect.height - 20) / 2)).toString() + 'px';
773
+ if (dir === 'left') {
774
+ form.elements.gesture.style.left = (rect.left + (offset / 1.5)).toString() + 'px';
787
775
  }
788
776
  else {
789
- dir = null;
790
- gestureElement.classList.remove('done');
777
+ form.elements.gesture.style.left = (rect.right - 20 - (offset / 1.5)).toString() + 'px';
791
778
  }
792
- gestureElement.style.left = (rect.left + ((rect.width - 20) / 2)).toString() + 'px';
793
- gestureElement.style.top = (rect.top + rect.height - 10 - (xyAbs / 1.5)).toString() + 'px';
794
- gestureElement.style.transform = 'scale(' + (xyAbs / 90).toString() + ')';
795
779
  }
796
780
  }
797
781
  },
798
782
  end: () => {
799
- gestureElement.style.opacity = '0';
800
- if (!dir) {
783
+ form.elements.gesture.style.opacity = '0';
784
+ if (offset < 90) {
801
785
  return;
802
786
  }
803
- opt.handler(dir);
787
+ handler(dir);
804
788
  }
805
789
  });
806
790
  }
807
791
  else {
808
- if (bindGestureData.el !== el) {
809
- bindGestureData.el = el;
810
- bindGestureData.xx = 0;
811
- bindGestureData.xy = 0;
812
- }
813
- let x = 0, y = 0;
814
- if (e instanceof WheelEvent) {
815
- e.preventDefault();
816
- if (Math.abs(e.deltaX) < 5 && Math.abs(e.deltaY) < 5) {
792
+ (() => __awaiter(this, void 0, void 0, function* () {
793
+ const now = Date.now();
794
+ if (now - gestureWheel.last > 250) {
795
+ gestureWheel.offset = 0;
796
+ gestureWheel.done = false;
797
+ gestureWheel.timer = 0;
798
+ gestureWheel.firstTimer = false;
799
+ gestureWheel.dir = '';
800
+ }
801
+ gestureWheel.last = now;
802
+ if (gestureWheel.firstTimer) {
817
803
  return;
818
804
  }
819
- x = Math.round(e.deltaX / 3);
820
- y = Math.round(e.deltaY / 3);
821
- if (e.direction === 'h') {
822
- x = y;
823
- y = 0;
805
+ if (gestureWheel.done) {
806
+ return;
824
807
  }
825
- else if (e.direction === 'v') {
826
- y = x;
827
- x = 0;
808
+ let deltaY = oe.deltaY;
809
+ let deltaX = oe.deltaX;
810
+ if (clickgo.dom.is.shift) {
811
+ deltaY = oe.deltaX;
812
+ deltaX = oe.deltaY;
828
813
  }
829
- }
830
- else {
831
- x = (_d = e.x) !== null && _d !== void 0 ? _d : 0;
832
- y = (_e = e.y) !== null && _e !== void 0 ? _e : 0;
833
- }
834
- let tx = bindGestureData.tx + x;
835
- if (tx > 90) {
836
- tx = 90;
837
- }
838
- else if (tx < -90) {
839
- tx = -90;
840
- }
841
- let ty = bindGestureData.ty + y;
842
- if (ty > 90) {
843
- ty = 90;
844
- }
845
- else if (ty < -90) {
846
- ty = -90;
847
- }
848
- bindGestureData.tx = tx;
849
- bindGestureData.ty = ty;
850
- if (bindGestureData.timers.ani !== 0) {
851
- cancelAnimationFrame(bindGestureData.timers.ani);
852
- bindGestureData.timers.ani = 0;
853
- }
854
- if (bindGestureData.timers.sleep !== 0) {
855
- clearTimeout(bindGestureData.timers.sleep);
856
- bindGestureData.timers.sleep = 0;
857
- }
858
- bindGestureAnimation({
859
- 'rect': rect,
860
- 'dirs': opt.dirs,
861
- 'handler': opt.handler
814
+ if (gestureWheel.dir === '') {
815
+ if (Math.abs(deltaY) > Math.abs(deltaX)) {
816
+ if (deltaY < 0) {
817
+ gestureWheel.dir = 'top';
818
+ }
819
+ else {
820
+ gestureWheel.dir = 'bottom';
821
+ }
822
+ }
823
+ else {
824
+ if (deltaX < 0) {
825
+ gestureWheel.dir = 'left';
826
+ }
827
+ else {
828
+ gestureWheel.dir = 'right';
829
+ }
830
+ }
831
+ if (!before(oe, gestureWheel.dir)) {
832
+ gestureWheel.done = true;
833
+ return;
834
+ }
835
+ form.elements.gesture.style.transform = 'scale(0)';
836
+ switch (gestureWheel.dir) {
837
+ case 'top':
838
+ case 'bottom': {
839
+ form.elements.gesture.style.left = (rect.left + ((rect.width - 20) / 2)).toString() + 'px';
840
+ if (gestureWheel.dir === 'top') {
841
+ form.elements.gesture.style.top = (rect.top + 10).toString() + 'px';
842
+ }
843
+ else {
844
+ form.elements.gesture.style.top = (rect.bottom - 10).toString() + 'px';
845
+ }
846
+ break;
847
+ }
848
+ default: {
849
+ form.elements.gesture.style.top = (rect.top + ((rect.height - 20) / 2)).toString() + 'px';
850
+ if (gestureWheel.dir === 'left') {
851
+ form.elements.gesture.style.left = (rect.left + 10).toString() + 'px';
852
+ }
853
+ else {
854
+ form.elements.gesture.style.left = (rect.right - 10).toString() + 'px';
855
+ }
856
+ }
857
+ }
858
+ gestureWheel.firstTimer = true;
859
+ yield tool.sleep(30);
860
+ gestureWheel.firstTimer = false;
861
+ form.elements.gesture.classList.add('ani');
862
+ }
863
+ switch (gestureWheel.dir) {
864
+ case 'top':
865
+ case 'bottom': {
866
+ gestureWheel.offset += (gestureWheel.dir === 'top') ? -deltaY : deltaY;
867
+ break;
868
+ }
869
+ default: {
870
+ gestureWheel.offset += (gestureWheel.dir === 'left') ? -deltaX : deltaX;
871
+ }
872
+ }
873
+ if (gestureWheel.offset < 0) {
874
+ gestureWheel.offset = 0;
875
+ form.elements.gesture.style.opacity = '0';
876
+ return;
877
+ }
878
+ form.elements.gesture.style.opacity = '1';
879
+ let offset = gestureWheel.offset / 1.38;
880
+ if (offset > 90) {
881
+ offset = 90;
882
+ form.elements.gesture.classList.add('done');
883
+ }
884
+ else {
885
+ form.elements.gesture.classList.remove('done');
886
+ }
887
+ form.elements.gesture.style.transform = 'scale(' + (offset / 90).toString() + ')';
888
+ switch (gestureWheel.dir) {
889
+ case 'top': {
890
+ form.elements.gesture.style.top = (rect.top + (offset / 1.5)).toString() + 'px';
891
+ break;
892
+ }
893
+ case 'bottom': {
894
+ form.elements.gesture.style.top = (rect.bottom - 20 - (offset / 1.5)).toString() + 'px';
895
+ break;
896
+ }
897
+ case 'left': {
898
+ form.elements.gesture.style.left = (rect.left + (offset / 1.5)).toString() + 'px';
899
+ break;
900
+ }
901
+ default: {
902
+ form.elements.gesture.style.left = (rect.right - 20 - (offset / 1.5)).toString() + 'px';
903
+ }
904
+ }
905
+ clearTimeout(gestureWheel.timer);
906
+ if (offset < 90) {
907
+ gestureWheel.timer = window.setTimeout(() => {
908
+ form.elements.gesture.style.opacity = '0';
909
+ form.elements.gesture.classList.remove('ani');
910
+ }, 250);
911
+ return;
912
+ }
913
+ gestureWheel.done = true;
914
+ handler(gestureWheel.dir);
915
+ yield tool.sleep(500);
916
+ form.elements.gesture.style.opacity = '0';
917
+ form.elements.gesture.classList.remove('ani');
918
+ }))().catch((e) => {
919
+ console.log('error', 'dom.bindGesture', e);
862
920
  });
863
921
  }
864
922
  }
@@ -939,9 +997,9 @@ function bindDrag(e, opt) {
939
997
  otop = rect.top;
940
998
  oleft = rect.left;
941
999
  },
942
- 'move': function (ox, oy, x, y) {
943
- const ntop = otop + oy;
944
- const nleft = oleft + ox;
1000
+ 'move': function (e, o) {
1001
+ const ntop = otop + o.oy;
1002
+ const nleft = oleft + o.ox;
945
1003
  form.moveDrag({
946
1004
  'top': ntop,
947
1005
  'left': nleft,
@@ -949,7 +1007,7 @@ function bindDrag(e, opt) {
949
1007
  });
950
1008
  otop = ntop;
951
1009
  oleft = nleft;
952
- const els = document.elementsFromPoint(x, y);
1010
+ const els = document.elementsFromPoint(o.x, o.y);
953
1011
  for (const el of els) {
954
1012
  if (el.dataset.cgDrop === undefined) {
955
1013
  continue;
@@ -1273,7 +1331,20 @@ function bindMove(e, opt) {
1273
1331
  'ox': ox,
1274
1332
  'oy': oy
1275
1333
  });
1276
- (_c = opt.move) === null || _c === void 0 ? void 0 : _c.call(opt, ox, oy, x, y, border, dir, e);
1334
+ (_c = opt.move) === null || _c === void 0 ? void 0 : _c.call(opt, e, {
1335
+ 'ox': ox,
1336
+ 'oy': oy,
1337
+ 'x': x,
1338
+ 'y': y,
1339
+ 'border': border,
1340
+ 'inBorder': {
1341
+ 'top': inBorderTop,
1342
+ 'right': inBorderRight,
1343
+ 'bottom': inBorderBottom,
1344
+ 'left': inBorderLeft
1345
+ },
1346
+ 'dir': dir
1347
+ });
1277
1348
  tx = x;
1278
1349
  ty = y;
1279
1350
  },
@@ -1376,23 +1447,23 @@ function bindResize(e, opt) {
1376
1447
  'offsetRight': offsetRight,
1377
1448
  'offsetBottom': offsetBottom,
1378
1449
  'start': opt.start,
1379
- 'move': function (ox, oy, x, y, border) {
1450
+ 'move': function (e, o) {
1380
1451
  var _a;
1381
1452
  if (opt.border === 'tr' || opt.border === 'r' || opt.border === 'rb') {
1382
- opt.objectWidth += ox;
1453
+ opt.objectWidth += o.ox;
1383
1454
  }
1384
1455
  else if (opt.border === 'bl' || opt.border === 'l' || opt.border === 'lt') {
1385
- opt.objectWidth -= ox;
1386
- opt.objectLeft += ox;
1456
+ opt.objectWidth -= o.ox;
1457
+ opt.objectLeft += o.ox;
1387
1458
  }
1388
1459
  if (opt.border === 'rb' || opt.border === 'b' || opt.border === 'bl') {
1389
- opt.objectHeight += oy;
1460
+ opt.objectHeight += o.oy;
1390
1461
  }
1391
1462
  else if (opt.border === 'lt' || opt.border === 't' || opt.border === 'tr') {
1392
- opt.objectHeight -= oy;
1393
- opt.objectTop += oy;
1463
+ opt.objectHeight -= o.oy;
1464
+ opt.objectTop += o.oy;
1394
1465
  }
1395
- (_a = opt.move) === null || _a === void 0 ? void 0 : _a.call(opt, opt.objectLeft, opt.objectTop, opt.objectWidth, opt.objectHeight, x, y, border);
1466
+ (_a = opt.move) === null || _a === void 0 ? void 0 : _a.call(opt, opt.objectLeft, opt.objectTop, opt.objectWidth, opt.objectHeight, x, y, o.border);
1396
1467
  },
1397
1468
  'end': opt.end
1398
1469
  });
@@ -1474,3 +1545,13 @@ function fullscreen() {
1474
1545
  }
1475
1546
  }
1476
1547
  exports.fullscreen = fullscreen;
1548
+ document.addEventListener('visibilitychange', function () {
1549
+ if (document.hidden) {
1550
+ cancelAnimationFrame(watchStyleTimer);
1551
+ cancelAnimationFrame(watchPropertyTimer);
1552
+ }
1553
+ else {
1554
+ watchStyleTimer = requestAnimationFrame(watchStyleHandler);
1555
+ watchPropertyTimer = requestAnimationFrame(watchPropertyHandler);
1556
+ }
1557
+ });