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.
- package/dist/app/demo/app.js +0 -73
- package/dist/app/demo/config.json +109 -0
- package/dist/app/demo/form/control/button/button.js +12 -11
- package/dist/app/demo/form/control/button/button.xml +6 -6
- package/dist/app/demo/form/control/check/check.js +14 -10
- package/dist/app/demo/form/control/file/file.js +15 -13
- package/dist/app/demo/form/control/{overflow/overflow.css → flow/flow.css} +0 -0
- package/dist/app/demo/form/control/flow/flow.js +64 -0
- package/dist/app/demo/form/control/{overflow/overflow.scss → flow/flow.scss} +0 -0
- package/dist/app/demo/form/control/flow/flow.xml +101 -0
- package/dist/app/demo/form/control/form/form.js +1 -1
- package/dist/app/demo/form/control/form/form.xml +3 -3
- package/dist/app/demo/form/control/img/img.xml +2 -2
- package/dist/app/demo/form/control/list/list.js +95 -75
- package/dist/app/demo/form/control/list/list.xml +15 -11
- package/dist/app/demo/form/control/marquee/marquee.js +12 -10
- package/dist/app/demo/form/control/menu/menu.js +10 -6
- package/dist/app/demo/form/control/monaco/monaco.js +50 -60
- package/dist/app/demo/form/control/monaco/monaco.xml +6 -5
- package/dist/app/demo/form/control/property/property.js +131 -127
- package/dist/app/demo/form/control/radio/radio.js +9 -5
- package/dist/app/demo/form/control/scroll/scroll.js +16 -12
- package/dist/app/demo/form/control/scroll/scroll.xml +10 -10
- package/dist/app/demo/form/control/select/select.js +132 -71
- package/dist/app/demo/form/control/select/select.xml +69 -67
- package/dist/app/demo/form/control/tab/tab.js +21 -20
- package/dist/app/demo/form/control/tab/tab.xml +2 -2
- package/dist/app/demo/form/control/text/text.js +53 -45
- package/dist/app/demo/form/control/text/text.xml +3 -3
- package/dist/app/demo/form/control/{greatview/greatview.css → vflow/vflow.css} +0 -0
- package/dist/app/demo/form/control/vflow/vflow.js +79 -0
- package/dist/app/demo/form/control/{greatview/greatview.scss → vflow/vflow.scss} +0 -0
- package/dist/app/demo/form/control/{greatview/greatview.xml → vflow/vflow.xml} +25 -25
- package/dist/app/demo/form/event/form/form.js +58 -56
- package/dist/app/demo/form/event/form/form.xml +3 -3
- package/dist/app/demo/form/event/screen/screen.js +30 -28
- package/dist/app/demo/form/event/screen/screen.xml +2 -2
- package/dist/app/demo/form/event/task/task.js +31 -31
- package/dist/app/demo/form/event/task/task.xml +3 -3
- package/dist/app/demo/form/main.js +161 -5
- package/dist/app/demo/form/main.xml +36 -35
- package/dist/app/demo/form/method/aform/aform.xml +3 -2
- package/dist/app/demo/form/method/core/core.js +11 -8
- package/dist/app/demo/form/method/core/core.xml +2 -1
- package/dist/app/demo/form/method/dom/dom.js +91 -99
- package/dist/app/demo/form/method/dom/dom.xml +6 -7
- package/dist/app/demo/form/method/form/form.js +8 -8
- package/dist/app/demo/form/method/form/form.xml +4 -4
- package/dist/app/demo/form/method/fs/fs.js +34 -33
- package/dist/app/demo/form/method/fs/fs.xml +1 -1
- package/dist/app/demo/form/method/fs/text.js +12 -12
- package/dist/app/demo/form/method/native/native.js +50 -0
- package/dist/app/demo/form/method/native/native.xml +12 -0
- package/dist/app/demo/form/method/system/system.js +50 -0
- package/dist/app/demo/form/method/system/system.xml +11 -0
- package/dist/app/demo/form/method/task/task.js +59 -61
- package/dist/app/demo/form/method/task/task.xml +4 -6
- package/dist/app/demo/form/method/theme/theme.js +14 -14
- package/dist/app/demo/form/method/tool/tool.js +29 -28
- package/dist/app/demo/form/method/tool/tool.xml +3 -3
- package/dist/app/demo/form/method/zip/zip.js +46 -41
- package/dist/app/demo/form/method/zip/zip.xml +1 -1
- package/dist/app/task/app.js +0 -25
- package/dist/app/task/config.json +29 -0
- package/dist/app/task/form/bar/bar.js +1 -1
- package/dist/app/task/form/bar/bar.xml +1 -1
- package/dist/clickgo.js +1 -1
- package/dist/clickgo.ts +1 -1
- package/dist/control/common.cgc +0 -0
- package/dist/control/form.cgc +0 -0
- package/dist/control/monaco.cgc +0 -0
- package/dist/control/property.cgc +0 -0
- package/dist/control/task.cgc +0 -0
- package/dist/global.css +1 -1
- package/dist/index.js +3 -3
- package/dist/index.ts +3 -3
- package/dist/lib/control.js +70 -104
- package/dist/lib/control.ts +97 -123
- package/dist/lib/core.js +108 -252
- package/dist/lib/core.ts +122 -268
- package/dist/lib/dom.js +564 -483
- package/dist/lib/dom.ts +703 -546
- package/dist/lib/form.js +146 -138
- package/dist/lib/form.ts +108 -86
- package/dist/lib/fs.js +1 -1
- package/dist/lib/fs.ts +1 -1
- package/dist/lib/native.js +135 -8
- package/dist/lib/native.ts +175 -11
- package/dist/lib/task.js +294 -158
- package/dist/lib/task.ts +326 -172
- package/dist/lib/tool.js +48 -1
- package/dist/lib/tool.ts +61 -0
- package/dist/lib/zip.ts +2 -0
- package/dist/theme/familiar.cgt +0 -0
- package/package.json +1 -1
- package/types/index.d.ts +23 -24
- package/dist/app/demo/form/control/greatview/greatview.js +0 -92
- package/dist/app/demo/form/control/overflow/overflow.js +0 -70
- package/dist/app/demo/form/control/overflow/overflow.xml +0 -98
- package/dist/app/demo/form/control/view/view.css +0 -1
- package/dist/app/demo/form/control/view/view.js +0 -73
- package/dist/app/demo/form/control/view/view.scss +0 -18
- 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.
|
|
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;
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
183
|
-
|
|
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
|
|
182
|
+
watchSizeList[watchSizeIndex] = {
|
|
191
183
|
'el': el,
|
|
192
|
-
'
|
|
184
|
+
'handler': cb,
|
|
193
185
|
'taskId': taskId
|
|
194
|
-
}
|
|
195
|
-
|
|
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
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
-
|
|
218
|
-
|
|
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
|
-
|
|
226
|
-
|
|
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
|
-
|
|
234
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
|
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
|
-
|
|
298
|
-
|
|
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
|
-
|
|
316
|
-
|
|
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
|
-
|
|
324
|
-
|
|
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
|
-
|
|
332
|
-
|
|
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
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
-
'
|
|
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
|
-
|
|
375
|
+
watchStyleList[formId][watchStyleIndex] = {
|
|
369
376
|
'el': el,
|
|
370
377
|
'sd': sd,
|
|
371
378
|
'names': {}
|
|
372
|
-
}
|
|
373
|
-
const item =
|
|
379
|
+
};
|
|
380
|
+
const item = watchStyleList[formId][watchStyleIndex];
|
|
374
381
|
for (const n of name) {
|
|
375
382
|
item.names[n] = {
|
|
376
|
-
'
|
|
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
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
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(
|
|
421
|
+
watchStyleTimer = requestAnimationFrame(watchStyleHandler);
|
|
404
422
|
};
|
|
405
|
-
|
|
423
|
+
watchStyleHandler();
|
|
406
424
|
function isWatchStyle(el) {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
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
|
|
470
|
+
return;
|
|
412
471
|
}
|
|
413
|
-
|
|
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.
|
|
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
|
|
527
|
-
'
|
|
528
|
-
'
|
|
529
|
-
'
|
|
530
|
-
'
|
|
531
|
-
'
|
|
532
|
-
'dir':
|
|
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
|
|
539
|
-
|
|
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
|
-
|
|
683
|
-
if (
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
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
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
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
|
-
|
|
724
|
-
|
|
725
|
-
|
|
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
|
-
|
|
730
|
-
|
|
731
|
-
|
|
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
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
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
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
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
|
-
|
|
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
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
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
|
-
|
|
771
|
-
gestureElement.classList.remove('done');
|
|
767
|
+
form.elements.gesture.style.top = (rect.bottom - 20 - (offset / 1.5)).toString() + 'px';
|
|
772
768
|
}
|
|
773
|
-
|
|
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
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
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
|
-
|
|
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
|
-
|
|
800
|
-
if (
|
|
783
|
+
form.elements.gesture.style.opacity = '0';
|
|
784
|
+
if (offset < 90) {
|
|
801
785
|
return;
|
|
802
786
|
}
|
|
803
|
-
|
|
787
|
+
handler(dir);
|
|
804
788
|
}
|
|
805
789
|
});
|
|
806
790
|
}
|
|
807
791
|
else {
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
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
|
-
|
|
820
|
-
|
|
821
|
-
if (e.direction === 'h') {
|
|
822
|
-
x = y;
|
|
823
|
-
y = 0;
|
|
805
|
+
if (gestureWheel.done) {
|
|
806
|
+
return;
|
|
824
807
|
}
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
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
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
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 (
|
|
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,
|
|
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 (
|
|
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
|
+
});
|