targetj 1.0.74 → 1.0.76
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/babel.config.json +17 -0
- package/build/$Dom.js +424 -0
- package/build/App.js +187 -0
- package/build/Bracket.js +157 -0
- package/build/BracketGenerator.js +86 -0
- package/build/Browser.js +105 -0
- package/build/ColorUtil.js +182 -0
- package/build/Dim.js +31 -0
- package/build/Easing.js +59 -0
- package/build/EventListener.js +664 -0
- package/build/LoadingManager.js +366 -0
- package/build/LocationManager.js +211 -0
- package/build/Moves.js +71 -0
- package/build/PageManager.js +113 -0
- package/build/SearchUtil.js +196 -0
- package/build/TModel.js +1000 -0
- package/build/TModelManager.js +605 -0
- package/build/TUtil.js +188 -0
- package/build/TargetExecutor.js +117 -0
- package/build/TargetManager.js +197 -0
- package/build/TargetUtil.js +299 -0
- package/build/Viewport.js +163 -0
- package/package.json +11 -4
- package/webpack.config.js +14 -1
- package/src/$Dom.js +0 -380
- package/src/App.js +0 -224
- package/src/Bracket.js +0 -212
- package/src/Browser.js +0 -122
- package/src/ColorUtil.js +0 -166
- package/src/Dim.js +0 -21
- package/src/Easing.js +0 -41
- package/src/EventListener.js +0 -570
- package/src/LoadingManager.js +0 -368
- package/src/LocationManager.js +0 -236
- package/src/Moves.js +0 -59
- package/src/PageManager.js +0 -87
- package/src/SearchUtil.js +0 -210
- package/src/TModel.js +0 -937
- package/src/TModelManager.js +0 -575
- package/src/TUtil.js +0 -162
- package/src/TargetExecutor.js +0 -113
- package/src/TargetManager.js +0 -191
- package/src/TargetUtil.js +0 -307
- package/src/Viewport.js +0 -180
package/src/LoadingManager.js
DELETED
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
import { $Dom } from "./$Dom.js";
|
|
2
|
-
import { browser } from "./Browser.js";
|
|
3
|
-
import { TUtil } from "./TUtil.js";
|
|
4
|
-
import { tapp } from "./App.js";
|
|
5
|
-
|
|
6
|
-
function LoadingManager() {
|
|
7
|
-
|
|
8
|
-
this.resultMap = {};
|
|
9
|
-
this.loadingMap = {};
|
|
10
|
-
|
|
11
|
-
this.singleLoadList = undefined;
|
|
12
|
-
this.groupLoadList = undefined;
|
|
13
|
-
this.imgLoadList = undefined;
|
|
14
|
-
|
|
15
|
-
this.stopLoadingAfterAttempts = TUtil.isDefined(tapp.stopLoadingAfterAttempts) ? tapp.stopLoadingAfterAttempts : 10;
|
|
16
|
-
this.attemptFailedInterval = TUtil.isDefined(tapp.attemptFailedInterval) ? tapp.attemptFailedInterval : 2000;
|
|
17
|
-
|
|
18
|
-
this.statistics = {};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
LoadingManager.prototype.initSingleLoad = function (fetchId, query, forceLoad) {
|
|
22
|
-
|
|
23
|
-
if (this.isLoading(fetchId) || (this.isLoaded(fetchId) && !forceLoad) || this.getLoadingAttempts(fetchId) > this.stopLoadingAfterAttempts) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
this.initLoadingMap(fetchId);
|
|
28
|
-
|
|
29
|
-
this.singleLoadList = this.singleLoadList ? this.singleLoadList : {};
|
|
30
|
-
this.singleLoadList[fetchId] = { fetchId: fetchId, query: query };
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
LoadingManager.prototype.initGroupLoad = function (fetchId, dataId, query, idKey, separator) {
|
|
34
|
-
var groupId = JSON.stringify({ query: query, idKey: idKey, separator: separator });
|
|
35
|
-
|
|
36
|
-
if (this.isLoading(fetchId) || this.isLoaded(fetchId) || this.getLoadingAttempts(fetchId) > this.stopLoadingAfterAttempts) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
this.initLoadingMap(fetchId);
|
|
41
|
-
|
|
42
|
-
this.groupLoadList = this.groupLoadList ? this.groupLoadList : {};
|
|
43
|
-
if (!this.groupLoadList[groupId]) {
|
|
44
|
-
this.groupLoadList[groupId] = [];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
this.groupLoadList[groupId].push({ fetchId: fetchId, dataId: dataId });
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
LoadingManager.prototype.initImgLoad = function (fetchId, src) {
|
|
51
|
-
|
|
52
|
-
if (this.isLoading(fetchId) || this.isLoaded(fetchId) || this.getLoadingAttempts(fetchId) > this.stopLoadingAfterAttempts) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
this.initLoadingMap(fetchId, 'image');
|
|
57
|
-
|
|
58
|
-
this.imgLoadList = this.imgLoadList ? this.imgLoadList : {};
|
|
59
|
-
this.imgLoadList[fetchId] = { fetchId: fetchId, src: src };
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
LoadingManager.prototype.isLoading = function(fetchId) {
|
|
63
|
-
return TUtil.isDefined(this.loadingMap[fetchId]) ? this.loadingMap[fetchId].loadingFlag : false;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
LoadingManager.prototype.isLoaded = function(fetchId) {
|
|
67
|
-
return TUtil.isDefined(this.resultMap[fetchId]) && this.resultMap[fetchId].success === true;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
LoadingManager.prototype.getLoadingAttempts = function(fetchId) {
|
|
71
|
-
return TUtil.isDefined(this.loadingMap[fetchId]) ? this.loadingMap[fetchId].attempts : 0;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
LoadingManager.prototype.getSuccessLoadingTime = function(fetchId) {
|
|
75
|
-
return TUtil.isDefined(this.loadingMap[fetchId]) && this.loadingMap[fetchId].success === true ? this.loadingMap[fetchId].loadingTime : undefined;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
LoadingManager.prototype.getFailedInterval = function(fetchId) {
|
|
79
|
-
return TUtil.isDefined(this.loadingMap[fetchId]) ? this.loadingMap[fetchId].attempts * this.attemptFailedInterval : 0;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
LoadingManager.prototype.fetchResult = function(fetchId) {
|
|
83
|
-
return this.resultMap[fetchId];
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
LoadingManager.prototype.hasLoadedSuccessfully = function(fetchId) {
|
|
87
|
-
return this.resultMap[fetchId] && this.resultMap[fetchId].success === true;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
LoadingManager.prototype.hasLoadedUnsuccessfully = function(fetchId) {
|
|
91
|
-
return this.resultMap[fetchId] && this.resultMap[fetchId].success === false;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
LoadingManager.prototype.fetchErrors = function(fetchId) {
|
|
95
|
-
return this.resultMap[fetchId] && this.resultMap[fetchId].result && this.resultMap[fetchId].result.errors ? this.resultMap[fetchId].result.errors : undefined;
|
|
96
|
-
};
|
|
97
|
-
LoadingManager.prototype.initLoadingMap = function(fetchId, category) {
|
|
98
|
-
category = category ? category : this.getCategoryFromFetchId(fetchId);
|
|
99
|
-
|
|
100
|
-
if (TUtil.isDefined(this.loadingMap[fetchId])) {
|
|
101
|
-
this.loadingMap[fetchId].loadingFlag = true;
|
|
102
|
-
this.loadingMap[fetchId].startTime = browser.now();
|
|
103
|
-
this.loadingMap[fetchId].loadingTime = undefined;
|
|
104
|
-
|
|
105
|
-
} else {
|
|
106
|
-
this.loadingMap[fetchId] = {
|
|
107
|
-
fetchId: fetchId,
|
|
108
|
-
category: category,
|
|
109
|
-
loadingFlag: true,
|
|
110
|
-
attempts: 0,
|
|
111
|
-
startTime: browser.now(),
|
|
112
|
-
loadingTime: undefined,
|
|
113
|
-
success: false
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
LoadingManager.prototype.groupLoad = function () {
|
|
119
|
-
if (!this.groupLoadList) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
var groupIds = Object.keys(this.groupLoadList);
|
|
124
|
-
|
|
125
|
-
for (var i = 0; i < groupIds.length; i++) {
|
|
126
|
-
var groupId = groupIds[i];
|
|
127
|
-
var fetchList = this.groupLoadList[groupId];
|
|
128
|
-
|
|
129
|
-
var dataIds = [], dataIdFetchIdMap = {};
|
|
130
|
-
|
|
131
|
-
for (var j = 0; j < fetchList.length; j++) {
|
|
132
|
-
var dataId = fetchList[j].dataId;
|
|
133
|
-
dataIds.push(dataId);
|
|
134
|
-
dataIdFetchIdMap[dataId] = fetchList[j].fetchId;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (dataIds.length > 0) {
|
|
138
|
-
var groupObj = JSON.parse(groupId);
|
|
139
|
-
var groupQuery = this.updateQueryValue(groupObj.query, dataIds.join(groupObj.separator));
|
|
140
|
-
this.groupAjax(groupQuery, dataIdFetchIdMap, groupObj.idKey);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
delete this.groupLoadList[groupId];
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
this.groupLoadList = undefined;
|
|
147
|
-
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
LoadingManager.prototype.singleLoad = function () {
|
|
151
|
-
if (!this.singleLoadList) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
var keys = Object.keys(this.singleLoadList);
|
|
156
|
-
|
|
157
|
-
for (var i = 0; i < keys.length; i++) {
|
|
158
|
-
var load = this.singleLoadList[keys[i]];
|
|
159
|
-
|
|
160
|
-
this.singleAjax(load.query, load.fetchId);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
this.singleLoadList = undefined;
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
LoadingManager.prototype.imgLoad = function () {
|
|
167
|
-
if (!this.imgLoadList) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
var keys = Object.keys(this.imgLoadList);
|
|
172
|
-
|
|
173
|
-
for (var i = 0; i < keys.length; i++) {
|
|
174
|
-
var load = this.imgLoadList[keys[i]];
|
|
175
|
-
|
|
176
|
-
this.imgAjax(load.src, load.fetchId);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
this.imgLoadList = undefined;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
LoadingManager.prototype.updateQueryValue = function(query, value) {
|
|
183
|
-
for (var prop in query) {
|
|
184
|
-
if (query[prop] === '%s') {
|
|
185
|
-
query[prop] = value;
|
|
186
|
-
} else if (query[prop] === '%d') {
|
|
187
|
-
query[prop] = typeof value === 'number' ? value : parseFloat(value);
|
|
188
|
-
} else if (typeof query[prop] === 'object') {
|
|
189
|
-
this.updateQueryValue(query[prop], value);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return query;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
LoadingManager.prototype.singleAjax = function (query, fetchId) {
|
|
196
|
-
var self = this;
|
|
197
|
-
|
|
198
|
-
var defaultQuery = {
|
|
199
|
-
dataType: "json",
|
|
200
|
-
type: "GET",
|
|
201
|
-
success: function (dataList) {
|
|
202
|
-
self.loadingMap[fetchId].loadingFlag = false;
|
|
203
|
-
self.loadingMap[fetchId].loadingTime = browser.now() - self.loadingMap[fetchId].startTime;
|
|
204
|
-
self.loadingMap[fetchId].success = true;
|
|
205
|
-
self.loadingMap[fetchId].attempts++;
|
|
206
|
-
|
|
207
|
-
self.resultMap[fetchId] = Object.assign({ result: dataList }, self.loadingMap[fetchId] );
|
|
208
|
-
delete self.loadingMap[fetchId];
|
|
209
|
-
|
|
210
|
-
self.updateStatistics(fetchId);
|
|
211
|
-
|
|
212
|
-
tapp.manager.scheduleRun(0, "singleAjax_success_" + fetchId);
|
|
213
|
-
},
|
|
214
|
-
error: function (textStatus) {
|
|
215
|
-
self.resultMap[fetchId] = { error: textStatus, success: false };
|
|
216
|
-
|
|
217
|
-
self.loadingMap[fetchId].loadingFlag = false;
|
|
218
|
-
self.loadingMap[fetchId].loadingTime = browser.now() - self.loadingMap[fetchId].startTime;
|
|
219
|
-
self.loadingMap[fetchId].attempts++;
|
|
220
|
-
|
|
221
|
-
tapp.manager.scheduleRun(0, "singleAjax_error_" + fetchId);
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
$Dom.ajax(Object.assign(defaultQuery, query));
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
LoadingManager.prototype.groupAjax = function (query, dataIdFetchIdMap, idKey) {
|
|
229
|
-
|
|
230
|
-
var self = this;
|
|
231
|
-
|
|
232
|
-
var defaultQuery = {
|
|
233
|
-
dataType: "json",
|
|
234
|
-
type: "GET",
|
|
235
|
-
success: function (dataList) {
|
|
236
|
-
for (var i = 0; i < dataList.length; i++) {
|
|
237
|
-
|
|
238
|
-
var dataId = dataList[i][idKey];
|
|
239
|
-
if (dataIdFetchIdMap[dataId]) {
|
|
240
|
-
var fetchId = dataIdFetchIdMap[dataId];
|
|
241
|
-
self.loadingMap[fetchId].loadingFlag = false;
|
|
242
|
-
self.loadingMap[fetchId].loadingTime = browser.now() - self.loadingMap[fetchId].startTime;
|
|
243
|
-
self.loadingMap[fetchId].success = true;
|
|
244
|
-
self.loadingMap[fetchId].attempts++;
|
|
245
|
-
|
|
246
|
-
self.resultMap[fetchId] = Object.assign({ result: dataList[i] }, self.loadingMap[fetchId] );
|
|
247
|
-
|
|
248
|
-
self.updateStatistics(fetchId);
|
|
249
|
-
|
|
250
|
-
delete self.loadingMap[fetchId];
|
|
251
|
-
delete dataIdFetchIdMap[dataId];
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
Object.keys(dataIdFetchIdMap).forEach(function(dataId) {
|
|
256
|
-
|
|
257
|
-
var fetchId = dataIdFetchIdMap[dataId];
|
|
258
|
-
|
|
259
|
-
if (!self.loadingMap[fetchId].success) {
|
|
260
|
-
self.loadingMap[fetchId].loadingFlag = false;
|
|
261
|
-
self.loadingMap[fetchId].loadingTime = browser.now() - self.loadingMap[fetchId].startTime;
|
|
262
|
-
self.loadingMap[fetchId].attempts++;
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
tapp.manager.scheduleRun(0, "groupAjax_success_" + query);
|
|
267
|
-
},
|
|
268
|
-
error: function (textStatus) {
|
|
269
|
-
Object.keys(dataIdFetchIdMap).forEach(function(dataId) {
|
|
270
|
-
var fetchId =dataIdFetchIdMap[dataId];
|
|
271
|
-
|
|
272
|
-
self.resultMap[fetchId] = { error: textStatus, success: false };
|
|
273
|
-
self.loadingMap[fetchId].loadingFlag = false;
|
|
274
|
-
self.loadingMap[fetchId].attempts++;
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
tapp.manager.scheduleRun(0, "groupAjax_error_" + query);
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
$Dom.ajax(Object.assign(defaultQuery, query));
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
LoadingManager.prototype.imgAjax = function (src, fetchId) {
|
|
285
|
-
var self = this;
|
|
286
|
-
|
|
287
|
-
var image = new Image();
|
|
288
|
-
image.src = src;
|
|
289
|
-
|
|
290
|
-
image.onload = function() {
|
|
291
|
-
self.loadingMap[fetchId].loadingFlag = false;
|
|
292
|
-
self.loadingMap[fetchId].loadingTime = browser.now() - self.loadingMap[fetchId].startTime;
|
|
293
|
-
self.loadingMap[fetchId].success = true;
|
|
294
|
-
self.loadingMap[fetchId].attempts++;
|
|
295
|
-
|
|
296
|
-
self.resultMap[fetchId] = Object.assign({ width: this.width, height: this.height, $image: new $Dom(image) }, self.loadingMap[fetchId]);
|
|
297
|
-
|
|
298
|
-
self.updateStatistics(fetchId, 'image');
|
|
299
|
-
delete self.loadingMap[fetchId];
|
|
300
|
-
|
|
301
|
-
tapp.manager.scheduleRun(0, "imgAjax_success_" + fetchId);
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
image.onerror = image.onabort = function () {
|
|
305
|
-
self.resultMap[fetchId] = { result: "no image", success: false };
|
|
306
|
-
|
|
307
|
-
self.loadingMap[fetchId].loadingFlag = false;
|
|
308
|
-
self.loadingMap[fetchId].loadingTime = browser.now() - self.loadingMap[fetchId].startTime;
|
|
309
|
-
self.loadingMap[fetchId].attempts++;
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
tapp.manager.scheduleRun(0, "imgAjax_error_" + fetchId);
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
LoadingManager.prototype.getCategoryFromFetchId = function(fetchId) {
|
|
318
|
-
return fetchId.replace(/[^a-zA-Z]/g, '');
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
LoadingManager.prototype.updateStatistics = function(fetchId, category) {
|
|
322
|
-
category = category ? category : this.getCategoryFromFetchId(fetchId);
|
|
323
|
-
|
|
324
|
-
if (this.statistics[category]) {
|
|
325
|
-
this.statistics[category].count++;
|
|
326
|
-
this.statistics[category].totalTime += this.resultMap[fetchId].loadingTime;
|
|
327
|
-
this.statistics[category].lastUpdate = browser.now();
|
|
328
|
-
delete this.statistics[category].averageTime;
|
|
329
|
-
} else {
|
|
330
|
-
this.statistics[category] = {
|
|
331
|
-
count: 1,
|
|
332
|
-
totalTime: this.resultMap[fetchId].loadingTime,
|
|
333
|
-
lastUpdate: browser.now()
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
LoadingManager.prototype.getAverageLoadingTime = function(category) {
|
|
339
|
-
var now = browser.now();
|
|
340
|
-
|
|
341
|
-
if (this.statistics[category] && this.statistics[category].averageTime && (now - this.statistics[category].lastUpdate) < 500) {
|
|
342
|
-
return this.statistics[category].averageTime;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
var totalTime = this.statistics[category] ? this.statistics[category].totalTime : 0;
|
|
346
|
-
var count = this.statistics[category] ? this.statistics[category].count : 0;
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
Object.values(this.loadingMap).filter(function(loadItem) { return loadItem.category === category; }).forEach(function(loadItem) {
|
|
350
|
-
totalTime += now - loadItem.startTime;
|
|
351
|
-
count++;
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
if (this.statistics[category]) {
|
|
355
|
-
|
|
356
|
-
this.statistics[category].averageTime = count > 0 ? totalTime / count : 0;
|
|
357
|
-
this.statistics[category].lastUpdate = browser.now();
|
|
358
|
-
|
|
359
|
-
return this.statistics[category].averageTime;
|
|
360
|
-
} else {
|
|
361
|
-
return 0;
|
|
362
|
-
}
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
export { LoadingManager };
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
package/src/LocationManager.js
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { Bracket } from "./Bracket.js";
|
|
2
|
-
import { TUtil } from "./TUtil.js";
|
|
3
|
-
import { TargetUtil } from "./TargetUtil.js";
|
|
4
|
-
import { TargetExecutor } from "./TargetExecutor.js";
|
|
5
|
-
import { tapp, getEvents, getScreenWidth, getScreenHeight } from "./App.js";
|
|
6
|
-
import { browser } from "./Browser.js";
|
|
7
|
-
|
|
8
|
-
function LocationManager() {
|
|
9
|
-
this.hasLocationList = [];
|
|
10
|
-
this.hasLocationMap = {};
|
|
11
|
-
|
|
12
|
-
this.bracketThreshold = 6;
|
|
13
|
-
this.locationCount = [];
|
|
14
|
-
|
|
15
|
-
this.screenWidth = getScreenWidth();
|
|
16
|
-
this.screenHeight = getScreenHeight();
|
|
17
|
-
this.resizeFlag = false;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
LocationManager.prototype.calculateAll = function() {
|
|
21
|
-
this.hasLocationList.length = 0;
|
|
22
|
-
this.hasLocationMap = {};
|
|
23
|
-
this.locationCount.length = 0;
|
|
24
|
-
this.startTime = browser.now();
|
|
25
|
-
this.resizeFlag = false;
|
|
26
|
-
|
|
27
|
-
if (this.screenWidth !== getScreenWidth() || this.screenHeight !== getScreenHeight()) {
|
|
28
|
-
this.resizeFlag = true;
|
|
29
|
-
this.screenWidth = getScreenWidth();
|
|
30
|
-
this.screenHeight = getScreenHeight();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
this.calculate();
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
LocationManager.prototype.calculate = function() {
|
|
37
|
-
this.addToLocationList(tapp.troot);
|
|
38
|
-
this.calculateContainer(tapp.troot);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
LocationManager.prototype.getChildren = function(container) {
|
|
42
|
-
var brackets;
|
|
43
|
-
|
|
44
|
-
if (this.isProlificContainer(container)) {
|
|
45
|
-
brackets = Bracket.generate(container);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return brackets ? brackets.list : container.getChildren();
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
LocationManager.prototype.isProlificContainer = function(container) {
|
|
52
|
-
return container.canBeBracketed() && container.getChildren().length > this.bracketThreshold;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
LocationManager.prototype.calculateContainer = function(container) {
|
|
56
|
-
var allChildren = this.getChildren(container);
|
|
57
|
-
|
|
58
|
-
var viewport = container.createViewport();
|
|
59
|
-
container.resetVisibleList();
|
|
60
|
-
|
|
61
|
-
var i = 0, length = allChildren.length;
|
|
62
|
-
|
|
63
|
-
while (i < length && tapp.isRunning()) {
|
|
64
|
-
|
|
65
|
-
var child = allChildren[i++];
|
|
66
|
-
if (!child) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
var outerXEast = undefined, innerXEast = undefined;
|
|
71
|
-
|
|
72
|
-
var preX = child.domValues.x;
|
|
73
|
-
var preY = child.domValues.y;
|
|
74
|
-
|
|
75
|
-
this.calculateTargets(child);
|
|
76
|
-
|
|
77
|
-
if (child.getActualValueLastUpdate('canBeBracketed') > child.getParent().getActualValueLastUpdate("allChildren")) {
|
|
78
|
-
delete child.getParent().targetValues['allChildren'];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
viewport.setCurrentChild(child);
|
|
82
|
-
child.setLocation(viewport);
|
|
83
|
-
child.calculateAbsolutePosition(child.x, child.y);
|
|
84
|
-
|
|
85
|
-
innerXEast = TUtil.isDefined(container.val('innerXEast')) ? container.val('innerXEast') : container.getInnerXEast();
|
|
86
|
-
outerXEast = TUtil.isDefined(child.val('outerXEast')) ? child.val('outerXEast') : child.getOuterXEast();
|
|
87
|
-
|
|
88
|
-
if (viewport.isOverflow(outerXEast, innerXEast)) {
|
|
89
|
-
viewport.overflow();
|
|
90
|
-
child.setLocation(viewport);
|
|
91
|
-
} else {
|
|
92
|
-
child.setLocation(viewport);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (child.isIncluded() && !this.hasLocationMap[child.oid]) {
|
|
96
|
-
this.addToLocationList(child);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (child.isTargetEnabled('x') && !child.isTargetUpdating('x') && !child.isTargetImperative('x') && child.getTargetSteps('x') === 0) {
|
|
100
|
-
TargetExecutor.resolveTargetValue(child, 'x');
|
|
101
|
-
TargetExecutor.snapActualToTarget(child, 'x');
|
|
102
|
-
} else if (!TUtil.isDefined(child.targetValues.x)) {
|
|
103
|
-
child.val('x', child.x);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (child.isTargetEnabled('y') && !child.isTargetUpdating('y') && !child.isTargetImperative('y') && child.getTargetSteps('y') === 0) {
|
|
107
|
-
TargetExecutor.resolveTargetValue(child, 'y');
|
|
108
|
-
TargetExecutor.snapActualToTarget(child, 'y');
|
|
109
|
-
} else if (!TUtil.isDefined(child.targetValues.y)) {
|
|
110
|
-
child.val('y', child.y);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (preX !== child.getX() || preY !== child.getY()) {
|
|
114
|
-
child.addToStyleTargetList('transform');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
child.calculateAbsolutePosition(child.getX(), child.getY());
|
|
118
|
-
|
|
119
|
-
viewport.isVisible(child);
|
|
120
|
-
|
|
121
|
-
child.addToParentVisibleList();
|
|
122
|
-
|
|
123
|
-
if (child.shouldCalculateChildren()) {
|
|
124
|
-
this.calculateContainer(child);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (child.isInFlow()) {
|
|
128
|
-
|
|
129
|
-
if (TUtil.isNumber(child.val('appendNewLine'))) {
|
|
130
|
-
viewport.appendNewLine();
|
|
131
|
-
viewport.calcContentWidthHeight();
|
|
132
|
-
} else {
|
|
133
|
-
viewport.calcContentWidthHeight();
|
|
134
|
-
viewport.nextLocation();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (Array.isArray(child.val('contentHeight'))) {
|
|
139
|
-
child.val('contentHeight').forEach(function(key) {
|
|
140
|
-
var preVal = child.val(key);
|
|
141
|
-
child.val(key, child.getContentHeight());
|
|
142
|
-
if (preVal !== child.val(key)) {
|
|
143
|
-
child.addToStyleTargetList(key);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (Array.isArray(child.val('contentWidth'))) {
|
|
149
|
-
child.val('contentWidth').forEach(function(key) {
|
|
150
|
-
var preVal = child.val(key);
|
|
151
|
-
child.val(key, child.getContentWidth());
|
|
152
|
-
if (preVal !== child.val(key)) {
|
|
153
|
-
child.addToStyleTargetList(key);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
viewport.calcContentWidthHeight();
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
this.locationCount.push(child.oid + "-" + child.updatingTargetList.length + "-" + (browser.now() - this.startTime));
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
LocationManager.prototype.calculateTargets = function(tmodel) {
|
|
167
|
-
this.activateTargetsOnEvents(tmodel);
|
|
168
|
-
tapp.targetManager.applyTargetValues(tmodel);
|
|
169
|
-
tapp.targetManager.setActualValues(tmodel);
|
|
170
|
-
|
|
171
|
-
if (tmodel.hasDom()) {
|
|
172
|
-
var preWidth = tmodel.getWidth();
|
|
173
|
-
var preHeight = tmodel.getHeight();
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if ((!TUtil.isDefined(tmodel.targetValues.width) && !TUtil.isDefined(tmodel.targets.width) && !TUtil.isDefined(tmodel.targetValues.contentWidth)) || tmodel.getTargetValue('widthFromDom')) {
|
|
177
|
-
TargetUtil.setWidthFromDom(tmodel);
|
|
178
|
-
}
|
|
179
|
-
if ((!TUtil.isDefined(tmodel.targetValues.height) && !TUtil.isDefined(tmodel.targets.height) && !TUtil.isDefined(tmodel.targetValues.contentHeight)) || tmodel.getTargetValue('heightFromDom')) {
|
|
180
|
-
TargetUtil.setHeightFromDom(tmodel);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (preWidth !== tmodel.getWidth() || preHeight !== tmodel.getHeight()) {
|
|
184
|
-
tmodel.addToStyleTargetList('dim');
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
LocationManager.prototype.activateTargetsOnEvents = function(tmodel) {
|
|
190
|
-
var activateTargets = [];
|
|
191
|
-
|
|
192
|
-
if (this.resizeFlag && tmodel.targets['onResize']) {
|
|
193
|
-
activateTargets = activateTargets.concat(tmodel.targets['onResize']);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (getEvents().isTouchHandler(tmodel) && tmodel.targets['onTouchEvent']) {
|
|
197
|
-
activateTargets = activateTargets.concat(tmodel.targets['onTouchEvent']);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (getEvents().isClickHandler(tmodel) && tmodel.targets['onClickEvent']) {
|
|
201
|
-
activateTargets = activateTargets.concat(tmodel.targets['onClickEvent']);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if ((getEvents().isScrollLeftHandler(tmodel) && getEvents().deltaX())
|
|
205
|
-
|| (getEvents().isScrollTopHandler(tmodel) && getEvents().deltaY())) {
|
|
206
|
-
if (tmodel.targets['onScrollEvent']) {
|
|
207
|
-
activateTargets = activateTargets.concat(tmodel.targets['onScrollEvent']);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (getEvents().currentKey && tmodel.targets['onKeyEvent']) {
|
|
212
|
-
activateTargets = activateTargets.concat(tmodel.targets['onKeyEvent']);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
activateTargets.forEach(function(target) {
|
|
216
|
-
var key, obj;
|
|
217
|
-
if (typeof target === 'object') {
|
|
218
|
-
key = target.key;
|
|
219
|
-
obj = target.tmodel || tmodel;
|
|
220
|
-
} else {
|
|
221
|
-
key = target;
|
|
222
|
-
obj = tmodel;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (obj.targets[key] && (obj.isTargetComplete(key) || obj.getTargetStatus(key) === '')) {
|
|
226
|
-
obj.activateTarget(key);
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
LocationManager.prototype.addToLocationList = function(child) {
|
|
232
|
-
this.hasLocationList.push(child);
|
|
233
|
-
this.hasLocationMap[child.oid] = child;
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
export { LocationManager };
|
package/src/Moves.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { getScreenWidth } from "./App.js";
|
|
2
|
-
|
|
3
|
-
function Moves() {}
|
|
4
|
-
|
|
5
|
-
Moves.bounce = function (from, to, initialX, initialWidth, initialHeight, bounceFactor, compressionFactor) {
|
|
6
|
-
|
|
7
|
-
initialX = initialX || getScreenWidth() / 2;
|
|
8
|
-
initialWidth = initialWidth || 50;
|
|
9
|
-
initialHeight = initialHeight || 50;
|
|
10
|
-
bounceFactor = bounceFactor || 0.6;
|
|
11
|
-
|
|
12
|
-
compressionFactor = compressionFactor || 0.2;
|
|
13
|
-
|
|
14
|
-
var bounce = to * bounceFactor;
|
|
15
|
-
var ys = [from];
|
|
16
|
-
var xs = [initialX];
|
|
17
|
-
var widths = [initialWidth];
|
|
18
|
-
var heights = [initialHeight];
|
|
19
|
-
|
|
20
|
-
while ((bounce | 0) > 1) {
|
|
21
|
-
ys.push(to);
|
|
22
|
-
ys.push(to - bounce);
|
|
23
|
-
|
|
24
|
-
var compressedWidth = initialWidth * (1 + compressionFactor);
|
|
25
|
-
var compressedHeight = initialHeight * (1 - compressionFactor);
|
|
26
|
-
|
|
27
|
-
widths.push(compressedWidth);
|
|
28
|
-
widths.push(initialWidth);
|
|
29
|
-
|
|
30
|
-
heights.push(compressedHeight);
|
|
31
|
-
heights.push(initialHeight);
|
|
32
|
-
|
|
33
|
-
xs.push(initialX - (compressedWidth - initialWidth) / 2);
|
|
34
|
-
xs.push(initialX);
|
|
35
|
-
|
|
36
|
-
bounce *= bounceFactor;
|
|
37
|
-
compressionFactor *= bounceFactor;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return { x: xs, y: ys, width: widths, height: heights };
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
Moves.spiral = function (startAngle, endAngle, angleStep, x, y, width, height) {
|
|
44
|
-
|
|
45
|
-
var xCoords = [], yCoords = [], rotations = [];
|
|
46
|
-
|
|
47
|
-
for (var angle = startAngle; angle <= endAngle; angle += angleStep) {
|
|
48
|
-
var radians = angle * (Math.PI / 180);
|
|
49
|
-
xCoords.push(Math.floor(x + width * Math.cos(radians)));
|
|
50
|
-
yCoords.push(Math.floor(y + height * Math.sin(radians)));
|
|
51
|
-
rotations.push(90 + angle);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return { x: xCoords, y: yCoords, rotate: rotations };
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
export { Moves };
|