@shijiu/jsview-vue 2.1.25 → 2.1.200
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/package.json +1 -1
- package/utils/JsViewEngineWidget/JsvFocusBlock.vue +1 -1
- package/utils/JsViewEngineWidget/JsvFocusHub.ts +123 -0
- package/utils/JsViewEngineWidget/JsvFocusManager.js +4 -3
- package/utils/JsViewEngineWidget/MetroWidget/AnimationManager.ts +145 -51
- package/utils/JsViewEngineWidget/MetroWidget/ListWidget.vue +51 -64
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +62 -71
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidgetSetup.js +308 -613
- package/utils/JsViewEngineWidget/TemplateParser/CommonMetroTemplate.ts +127 -247
- package/utils/JsViewEngineWidget/TemplateParser/ListMetroTemplate.ts +1 -0
- package/utils/JsViewEngineWidget/TemplateParser/MetroTemplate.ts +36 -2
- package/utils/JsViewEngineWidget/WidgetCommon.ts +25 -6
- package/utils/JsViewPlugin/JsvAudio/{JsvAudioBrowser.vue → BrowserAudio/BrowserAudio.vue} +1 -1
- package/utils/JsViewPlugin/JsvAudio/index.js +1 -1
- package/utils/JsViewPlugin/JsvLatex/BrowserDomBuilder.js +37 -0
- package/utils/JsViewPlugin/JsvLatex/Color.ts +43 -0
- package/utils/JsViewPlugin/JsvLatex/JsvLatex.vue +159 -0
- package/utils/JsViewPlugin/JsvLatex/JsvLatexBridgeProxy.js +16 -0
- package/utils/JsViewPlugin/JsvLatex/JsvLatexBrowser.vue +59 -0
- package/utils/JsViewPlugin/JsvLatex/PluginLoader.js +171 -0
- package/utils/JsViewPlugin/JsvLatex/index.js +28 -0
- package/utils/JsViewPlugin/JsvLatex/mathjax-tex-svg.txt +1 -0
- package/utils/JsViewPlugin/JsvLatex/version.js +24 -0
- package/utils/JsViewPlugin/JsvLatex/version.mjs +24 -0
- package/utils/JsViewPlugin/index.js +2 -1
- package/utils/JsViewVueTools/JsvDynamicCssStyle.js +2 -52
- package/utils/JsViewVueTools/JsvPerformance.ts +11 -0
- package/utils/JsViewVueTools/JsvPreDownloader.ts +55 -11
- package/utils/JsViewVueTools/JsvStyleSheetsDeclarer.js +40 -0
- package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/CanvasTexture.ts +143 -0
- package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/CommandList.ts +24 -0
- package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/Path.ts +198 -0
- package/utils/JsViewVueTools/JsvTextureStore/JsvTextureStore.ts +31 -0
- package/utils/JsViewVueTools/JsvTextureStore/Store.ts +32 -0
- package/utils/JsViewVueTools/JsvTextureStore/Texture.ts +38 -0
- package/utils/JsViewVueTools/index.js +3 -0
- package/utils/JsViewVueWidget/JsvEnableRenderBreak.vue +17 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ActionRefObject.ts +6 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ActorControl.ts +144 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ActorState.ts +6 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/{CallbackManager.js → CallbackManager.ts} +19 -10
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ForgeTypeDefine.ts +45 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/FreeMoveActor.vue +1 -1
- package/utils/JsViewVueWidget/JsvFreeMoveActor/JsvEnvBlocker.vue +124 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/KeepFlags.ts +6 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetAction.ts +553 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetCondition.ts +138 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetState.ts +53 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/index.js +11 -1
- package/utils/JsViewVueWidget/JsvHole.js +1 -1
- package/utils/JsViewVueWidget/JsvLine/JsvLine.vue +101 -0
- package/utils/JsViewVueWidget/JsvLine/LineManager.js +62 -0
- package/utils/JsViewVueWidget/JsvLine/index.js +3 -0
- package/utils/JsViewVueWidget/JsvMarquee.vue +316 -139
- package/utils/JsViewVueWidget/JsvMindMap/CommonType.ts +1 -0
- package/utils/JsViewVueWidget/JsvMindMap/Constant.ts +20 -0
- package/utils/JsViewVueWidget/JsvMindMap/DataTree.ts +394 -0
- package/utils/JsViewVueWidget/JsvMindMap/Geometry.ts +277 -0
- package/utils/JsViewVueWidget/JsvMindMap/JsvMindMap.vue +653 -0
- package/utils/JsViewVueWidget/JsvMindMap/index.js +1 -0
- package/utils/JsViewVueWidget/JsvMindMap/rtree.js +628 -0
- package/utils/JsViewVueWidget/JsvNinePatch.vue +2 -2
- package/utils/JsViewVueWidget/JsvPieChart.vue +124 -0
- package/utils/JsViewVueWidget/JsvPosterImage.vue +32 -9
- package/utils/JsViewVueWidget/JsvPreload/BrowserPreload.vue +135 -133
- package/utils/JsViewVueWidget/JsvPreload/JsvPreload.vue +273 -270
- package/utils/JsViewVueWidget/JsvSector.vue +107 -0
- package/utils/JsViewVueWidget/JsvTextBox.vue +14 -1
- package/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue +28 -2
- package/utils/JsViewVueWidget/JsvVisibleSensor/JsvVisibleSensor.vue +122 -93
- package/utils/JsViewVueWidget/index.js +15 -7
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ActorControl.js +0 -112
- package/utils/JsViewVueWidget/JsvFreeMoveActor/CommonTools.js +0 -18
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetAction.js +0 -216
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetCondition.js +0 -66
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetState.js +0 -38
- package/utils/JsViewVueWidget/JsvFreeMoveActor/TypeDefine.js +0 -12
- package/utils/JsViewVueWidget/JsvTouchContainer.vue +0 -183
- package/utils/JsViewVueWidget/JsvTransparentDiv.vue +0 -87
- /package/utils/{JsViewVueWidget → JsViewPlugin/JsvAudio/BrowserAudio}/JsvSystemAudio.vue +0 -0
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
|
|
2
|
+
function quickselect(arr, k, left, right, compare) {
|
|
3
|
+
quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function quickselectStep(arr, k, left, right, compare) {
|
|
7
|
+
|
|
8
|
+
while (right > left) {
|
|
9
|
+
if (right - left > 600) {
|
|
10
|
+
var n = right - left + 1;
|
|
11
|
+
var m = k - left + 1;
|
|
12
|
+
var z = Math.log(n);
|
|
13
|
+
var s = 0.5 * Math.exp(2 * z / 3);
|
|
14
|
+
var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
|
|
15
|
+
var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
|
|
16
|
+
var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
|
|
17
|
+
quickselectStep(arr, k, newLeft, newRight, compare);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var t = arr[k];
|
|
21
|
+
var i = left;
|
|
22
|
+
var j = right;
|
|
23
|
+
|
|
24
|
+
swap(arr, left, k);
|
|
25
|
+
if (compare(arr[right], t) > 0) { swap(arr, left, right); }
|
|
26
|
+
|
|
27
|
+
while (i < j) {
|
|
28
|
+
swap(arr, i, j);
|
|
29
|
+
i++;
|
|
30
|
+
j--;
|
|
31
|
+
while (compare(arr[i], t) < 0) { i++; }
|
|
32
|
+
while (compare(arr[j], t) > 0) { j--; }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (compare(arr[left], t) === 0) { swap(arr, left, j); }
|
|
36
|
+
else {
|
|
37
|
+
j++;
|
|
38
|
+
swap(arr, j, right);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (j <= k) { left = j + 1; }
|
|
42
|
+
if (k <= j) { right = j - 1; }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function swap(arr, i, j) {
|
|
47
|
+
var tmp = arr[i];
|
|
48
|
+
arr[i] = arr[j];
|
|
49
|
+
arr[j] = tmp;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function defaultCompare(a, b) {
|
|
53
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var RBush = function RBush(maxEntries) {
|
|
57
|
+
if (maxEntries === void 0) maxEntries = 9;
|
|
58
|
+
|
|
59
|
+
// max entries in a node is 9 by default; min node fill is 40% for best performance
|
|
60
|
+
this._maxEntries = Math.max(4, maxEntries);
|
|
61
|
+
this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
|
|
62
|
+
this.clear();
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
RBush.prototype.all = function all() {
|
|
66
|
+
return this._all(this.data, []);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
RBush.prototype.search = function search(bbox) {
|
|
70
|
+
var node = this.data;
|
|
71
|
+
var result = [];
|
|
72
|
+
|
|
73
|
+
if (!intersects(bbox, node)) { return result; }
|
|
74
|
+
|
|
75
|
+
var toBBox = this.toBBox;
|
|
76
|
+
var nodesToSearch = [];
|
|
77
|
+
|
|
78
|
+
while (node) {
|
|
79
|
+
for (var i = 0; i < node.children.length; i++) {
|
|
80
|
+
var child = node.children[i];
|
|
81
|
+
var childBBox = node.leaf ? toBBox(child) : child;
|
|
82
|
+
|
|
83
|
+
if (intersects(bbox, childBBox)) {
|
|
84
|
+
if (node.leaf) { result.push(child); }
|
|
85
|
+
else if (contains(bbox, childBBox)) { this._all(child, result); }
|
|
86
|
+
else { nodesToSearch.push(child); }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
node = nodesToSearch.pop();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return result;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
RBush.prototype.collides = function collides(bbox) {
|
|
96
|
+
var node = this.data;
|
|
97
|
+
|
|
98
|
+
if (!intersects(bbox, node)) { return false; }
|
|
99
|
+
|
|
100
|
+
var nodesToSearch = [];
|
|
101
|
+
while (node) {
|
|
102
|
+
for (var i = 0; i < node.children.length; i++) {
|
|
103
|
+
var child = node.children[i];
|
|
104
|
+
var childBBox = node.leaf ? this.toBBox(child) : child;
|
|
105
|
+
|
|
106
|
+
if (intersects(bbox, childBBox)) {
|
|
107
|
+
if (node.leaf || contains(bbox, childBBox)) { return true; }
|
|
108
|
+
nodesToSearch.push(child);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
node = nodesToSearch.pop();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return false;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
RBush.prototype.load = function load(data) {
|
|
118
|
+
if (!(data && data.length)) { return this; }
|
|
119
|
+
|
|
120
|
+
if (data.length < this._minEntries) {
|
|
121
|
+
for (var i = 0; i < data.length; i++) {
|
|
122
|
+
this.insert(data[i]);
|
|
123
|
+
}
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// recursively build the tree with the given data from scratch using OMT algorithm
|
|
128
|
+
var node = this._build(data.slice(), 0, data.length - 1, 0);
|
|
129
|
+
|
|
130
|
+
if (!this.data.children.length) {
|
|
131
|
+
// save as is if tree is empty
|
|
132
|
+
this.data = node;
|
|
133
|
+
|
|
134
|
+
} else if (this.data.height === node.height) {
|
|
135
|
+
// split root if trees have the same height
|
|
136
|
+
this._splitRoot(this.data, node);
|
|
137
|
+
|
|
138
|
+
} else {
|
|
139
|
+
if (this.data.height < node.height) {
|
|
140
|
+
// swap trees if inserted one is bigger
|
|
141
|
+
var tmpNode = this.data;
|
|
142
|
+
this.data = node;
|
|
143
|
+
node = tmpNode;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// insert the small tree into the large tree at appropriate level
|
|
147
|
+
this._insert(node, this.data.height - node.height - 1, true);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return this;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
RBush.prototype.insert = function insert(item) {
|
|
154
|
+
if (item) { this._insert(item, this.data.height - 1); }
|
|
155
|
+
return this;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
RBush.prototype.clear = function clear() {
|
|
159
|
+
this.data = createNode([]);
|
|
160
|
+
return this;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
RBush.prototype.trace = function trace(item, equalsFn, indexGetter = null) {
|
|
164
|
+
if (!item) { return []; }
|
|
165
|
+
|
|
166
|
+
var node = this.data;
|
|
167
|
+
var bbox = this.toBBox(item);
|
|
168
|
+
var path = [];
|
|
169
|
+
var indexes = [];
|
|
170
|
+
var i, parent, goingUp;
|
|
171
|
+
let found = false;
|
|
172
|
+
|
|
173
|
+
// depth-first iterative tree traversal
|
|
174
|
+
while (node || path.length) {
|
|
175
|
+
if (!node) { // go up
|
|
176
|
+
node = path.pop();
|
|
177
|
+
parent = path[path.length - 1];
|
|
178
|
+
i = indexes.pop();
|
|
179
|
+
goingUp = true;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (node.leaf) { // check current node
|
|
183
|
+
var index = findItem(item, node.children, equalsFn);
|
|
184
|
+
|
|
185
|
+
if (index !== -1) {
|
|
186
|
+
// item found, remove the item and condense tree upwards
|
|
187
|
+
if (indexGetter) {
|
|
188
|
+
indexGetter.value = index;
|
|
189
|
+
}
|
|
190
|
+
path.push(node);
|
|
191
|
+
found = true;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (!goingUp && !node.leaf && contains(node, bbox)) { // go down
|
|
197
|
+
path.push(node);
|
|
198
|
+
indexes.push(i);
|
|
199
|
+
i = 0;
|
|
200
|
+
parent = node;
|
|
201
|
+
node = node.children[0];
|
|
202
|
+
|
|
203
|
+
} else if (parent) { // go right
|
|
204
|
+
i++;
|
|
205
|
+
node = parent.children[i];
|
|
206
|
+
goingUp = false;
|
|
207
|
+
|
|
208
|
+
} else { node = null; } // nothing found
|
|
209
|
+
}
|
|
210
|
+
return found ? path : [];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
RBush.prototype.remove = function remove(item, equalsFn) {
|
|
214
|
+
if (!item) { return this; }
|
|
215
|
+
const index = {};
|
|
216
|
+
const trace = this.trace(item, equalsFn, index);
|
|
217
|
+
if (trace.length > 0) {
|
|
218
|
+
trace[trace.length - 1].splice(index.value)
|
|
219
|
+
this._condense(trace);
|
|
220
|
+
}
|
|
221
|
+
return this;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 原代码
|
|
225
|
+
if (!item) { return this; }
|
|
226
|
+
var node = this.data;
|
|
227
|
+
var bbox = this.toBBox(item);
|
|
228
|
+
var path = [];
|
|
229
|
+
var indexes = [];
|
|
230
|
+
var i, parent, goingUp;
|
|
231
|
+
|
|
232
|
+
// depth-first iterative tree traversal
|
|
233
|
+
while (node || path.length) {
|
|
234
|
+
|
|
235
|
+
if (!node) { // go up
|
|
236
|
+
node = path.pop();
|
|
237
|
+
parent = path[path.length - 1];
|
|
238
|
+
i = indexes.pop();
|
|
239
|
+
goingUp = true;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (node.leaf) { // check current node
|
|
243
|
+
var index = findItem(item, node.children, equalsFn);
|
|
244
|
+
|
|
245
|
+
if (index !== -1) {
|
|
246
|
+
// item found, remove the item and condense tree upwards
|
|
247
|
+
node.children.splice(index, 1);
|
|
248
|
+
path.push(node);
|
|
249
|
+
this._condense(path);
|
|
250
|
+
return this;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (!goingUp && !node.leaf && contains(node, bbox)) { // go down
|
|
255
|
+
path.push(node);
|
|
256
|
+
indexes.push(i);
|
|
257
|
+
i = 0;
|
|
258
|
+
parent = node;
|
|
259
|
+
node = node.children[0];
|
|
260
|
+
|
|
261
|
+
} else if (parent) { // go right
|
|
262
|
+
i++;
|
|
263
|
+
node = parent.children[i];
|
|
264
|
+
goingUp = false;
|
|
265
|
+
|
|
266
|
+
} else { node = null; } // nothing found
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return this;
|
|
270
|
+
*/
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
RBush.prototype.toBBox = function toBBox(item) { return item; };
|
|
274
|
+
|
|
275
|
+
RBush.prototype.compareMinX = function compareMinX(a, b) { return a.minX - b.minX; };
|
|
276
|
+
RBush.prototype.compareMinY = function compareMinY(a, b) { return a.minY - b.minY; };
|
|
277
|
+
|
|
278
|
+
RBush.prototype.toJSON = function toJSON() { return this.data; };
|
|
279
|
+
|
|
280
|
+
RBush.prototype.fromJSON = function fromJSON(data) {
|
|
281
|
+
this.data = data;
|
|
282
|
+
return this;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
RBush.prototype._all = function _all(node, result) {
|
|
286
|
+
var nodesToSearch = [];
|
|
287
|
+
while (node) {
|
|
288
|
+
if (node.leaf) { result.push.apply(result, node.children); }
|
|
289
|
+
else { nodesToSearch.push.apply(nodesToSearch, node.children); }
|
|
290
|
+
|
|
291
|
+
node = nodesToSearch.pop();
|
|
292
|
+
}
|
|
293
|
+
return result;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
RBush.prototype._build = function _build(items, left, right, height) {
|
|
297
|
+
|
|
298
|
+
var N = right - left + 1;
|
|
299
|
+
var M = this._maxEntries;
|
|
300
|
+
var node;
|
|
301
|
+
|
|
302
|
+
if (N <= M) {
|
|
303
|
+
// reached leaf level; return leaf
|
|
304
|
+
node = createNode(items.slice(left, right + 1));
|
|
305
|
+
calcBBox(node, this.toBBox);
|
|
306
|
+
return node;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (!height) {
|
|
310
|
+
// target height of the bulk-loaded tree
|
|
311
|
+
height = Math.ceil(Math.log(N) / Math.log(M));
|
|
312
|
+
|
|
313
|
+
// target number of root entries to maximize storage utilization
|
|
314
|
+
M = Math.ceil(N / Math.pow(M, height - 1));
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
node = createNode([]);
|
|
318
|
+
node.leaf = false;
|
|
319
|
+
node.height = height;
|
|
320
|
+
|
|
321
|
+
// split the items into M mostly square tiles
|
|
322
|
+
|
|
323
|
+
var N2 = Math.ceil(N / M);
|
|
324
|
+
var N1 = N2 * Math.ceil(Math.sqrt(M));
|
|
325
|
+
|
|
326
|
+
multiSelect(items, left, right, N1, this.compareMinX);
|
|
327
|
+
|
|
328
|
+
for (var i = left; i <= right; i += N1) {
|
|
329
|
+
|
|
330
|
+
var right2 = Math.min(i + N1 - 1, right);
|
|
331
|
+
|
|
332
|
+
multiSelect(items, i, right2, N2, this.compareMinY);
|
|
333
|
+
|
|
334
|
+
for (var j = i; j <= right2; j += N2) {
|
|
335
|
+
|
|
336
|
+
var right3 = Math.min(j + N2 - 1, right2);
|
|
337
|
+
|
|
338
|
+
// pack each entry recursively
|
|
339
|
+
node.children.push(this._build(items, j, right3, height - 1));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
calcBBox(node, this.toBBox);
|
|
344
|
+
|
|
345
|
+
return node;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
RBush.prototype._chooseSubtree = function _chooseSubtree(bbox, node, level, path) {
|
|
349
|
+
while (true) {
|
|
350
|
+
path.push(node);
|
|
351
|
+
|
|
352
|
+
if (node.leaf || path.length - 1 === level) { break; }
|
|
353
|
+
|
|
354
|
+
var minArea = Infinity;
|
|
355
|
+
var minEnlargement = Infinity;
|
|
356
|
+
var targetNode = (void 0);
|
|
357
|
+
|
|
358
|
+
for (var i = 0; i < node.children.length; i++) {
|
|
359
|
+
var child = node.children[i];
|
|
360
|
+
var area = bboxArea(child);
|
|
361
|
+
var enlargement = enlargedArea(bbox, child) - area;
|
|
362
|
+
|
|
363
|
+
// choose entry with the least area enlargement
|
|
364
|
+
if (enlargement < minEnlargement) {
|
|
365
|
+
minEnlargement = enlargement;
|
|
366
|
+
minArea = area < minArea ? area : minArea;
|
|
367
|
+
targetNode = child;
|
|
368
|
+
|
|
369
|
+
} else if (enlargement === minEnlargement) {
|
|
370
|
+
// otherwise choose one with the smallest area
|
|
371
|
+
if (area < minArea) {
|
|
372
|
+
minArea = area;
|
|
373
|
+
targetNode = child;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
node = targetNode || node.children[0];
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return node;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
RBush.prototype._insert = function _insert(item, level, isNode) {
|
|
385
|
+
var bbox = isNode ? item : this.toBBox(item);
|
|
386
|
+
var insertPath = [];
|
|
387
|
+
|
|
388
|
+
// find the best node for accommodating the item, saving all nodes along the path too
|
|
389
|
+
var node = this._chooseSubtree(bbox, this.data, level, insertPath);
|
|
390
|
+
|
|
391
|
+
// put the item into the node
|
|
392
|
+
node.children.push(item);
|
|
393
|
+
extend(node, bbox);
|
|
394
|
+
|
|
395
|
+
// split on node overflow; propagate upwards if necessary
|
|
396
|
+
while (level >= 0) {
|
|
397
|
+
if (insertPath[level].children.length > this._maxEntries) {
|
|
398
|
+
this._split(insertPath, level);
|
|
399
|
+
level--;
|
|
400
|
+
} else { break; }
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// adjust bboxes along the insertion path
|
|
404
|
+
this._adjustParentBBoxes(bbox, insertPath, level);
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// split overflowed node into two
|
|
408
|
+
RBush.prototype._split = function _split(insertPath, level) {
|
|
409
|
+
var node = insertPath[level];
|
|
410
|
+
var M = node.children.length;
|
|
411
|
+
var m = this._minEntries;
|
|
412
|
+
|
|
413
|
+
this._chooseSplitAxis(node, m, M);
|
|
414
|
+
|
|
415
|
+
var splitIndex = this._chooseSplitIndex(node, m, M);
|
|
416
|
+
|
|
417
|
+
var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
|
|
418
|
+
newNode.height = node.height;
|
|
419
|
+
newNode.leaf = node.leaf;
|
|
420
|
+
|
|
421
|
+
calcBBox(node, this.toBBox);
|
|
422
|
+
calcBBox(newNode, this.toBBox);
|
|
423
|
+
|
|
424
|
+
if (level) { insertPath[level - 1].children.push(newNode); }
|
|
425
|
+
else { this._splitRoot(node, newNode); }
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
RBush.prototype._splitRoot = function _splitRoot(node, newNode) {
|
|
429
|
+
// split root node
|
|
430
|
+
this.data = createNode([node, newNode]);
|
|
431
|
+
this.data.height = node.height + 1;
|
|
432
|
+
this.data.leaf = false;
|
|
433
|
+
calcBBox(this.data, this.toBBox);
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
RBush.prototype._chooseSplitIndex = function _chooseSplitIndex(node, m, M) {
|
|
437
|
+
var index;
|
|
438
|
+
var minOverlap = Infinity;
|
|
439
|
+
var minArea = Infinity;
|
|
440
|
+
|
|
441
|
+
for (var i = m; i <= M - m; i++) {
|
|
442
|
+
var bbox1 = distBBox(node, 0, i, this.toBBox);
|
|
443
|
+
var bbox2 = distBBox(node, i, M, this.toBBox);
|
|
444
|
+
|
|
445
|
+
var overlap = intersectionArea(bbox1, bbox2);
|
|
446
|
+
var area = bboxArea(bbox1) + bboxArea(bbox2);
|
|
447
|
+
|
|
448
|
+
// choose distribution with minimum overlap
|
|
449
|
+
if (overlap < minOverlap) {
|
|
450
|
+
minOverlap = overlap;
|
|
451
|
+
index = i;
|
|
452
|
+
|
|
453
|
+
minArea = area < minArea ? area : minArea;
|
|
454
|
+
|
|
455
|
+
} else if (overlap === minOverlap) {
|
|
456
|
+
// otherwise choose distribution with minimum area
|
|
457
|
+
if (area < minArea) {
|
|
458
|
+
minArea = area;
|
|
459
|
+
index = i;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return index || M - m;
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
// sorts node children by the best axis for split
|
|
468
|
+
RBush.prototype._chooseSplitAxis = function _chooseSplitAxis(node, m, M) {
|
|
469
|
+
var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX;
|
|
470
|
+
var compareMinY = node.leaf ? this.compareMinY : compareNodeMinY;
|
|
471
|
+
var xMargin = this._allDistMargin(node, m, M, compareMinX);
|
|
472
|
+
var yMargin = this._allDistMargin(node, m, M, compareMinY);
|
|
473
|
+
|
|
474
|
+
// if total distributions margin value is minimal for x, sort by minX,
|
|
475
|
+
// otherwise it's already sorted by minY
|
|
476
|
+
if (xMargin < yMargin) { node.children.sort(compareMinX); }
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
// total margin of all possible split distributions where each node is at least m full
|
|
480
|
+
RBush.prototype._allDistMargin = function _allDistMargin(node, m, M, compare) {
|
|
481
|
+
node.children.sort(compare);
|
|
482
|
+
|
|
483
|
+
var toBBox = this.toBBox;
|
|
484
|
+
var leftBBox = distBBox(node, 0, m, toBBox);
|
|
485
|
+
var rightBBox = distBBox(node, M - m, M, toBBox);
|
|
486
|
+
var margin = bboxMargin(leftBBox) + bboxMargin(rightBBox);
|
|
487
|
+
|
|
488
|
+
for (var i = m; i < M - m; i++) {
|
|
489
|
+
var child = node.children[i];
|
|
490
|
+
extend(leftBBox, node.leaf ? toBBox(child) : child);
|
|
491
|
+
margin += bboxMargin(leftBBox);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
for (var i$1 = M - m - 1; i$1 >= m; i$1--) {
|
|
495
|
+
var child$1 = node.children[i$1];
|
|
496
|
+
extend(rightBBox, node.leaf ? toBBox(child$1) : child$1);
|
|
497
|
+
margin += bboxMargin(rightBBox);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return margin;
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
RBush.prototype._adjustParentBBoxes = function _adjustParentBBoxes(bbox, path, level) {
|
|
504
|
+
// adjust bboxes along the given tree path
|
|
505
|
+
for (var i = level; i >= 0; i--) {
|
|
506
|
+
extend(path[i], bbox);
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
RBush.prototype._condense = function _condense(path) {
|
|
511
|
+
// go through the path, removing empty nodes and updating bboxes
|
|
512
|
+
for (var i = path.length - 1, siblings = (void 0); i >= 0; i--) {
|
|
513
|
+
if (path[i].children.length === 0) {
|
|
514
|
+
if (i > 0) {
|
|
515
|
+
siblings = path[i - 1].children;
|
|
516
|
+
siblings.splice(siblings.indexOf(path[i]), 1);
|
|
517
|
+
|
|
518
|
+
} else { this.clear(); }
|
|
519
|
+
|
|
520
|
+
} else { calcBBox(path[i], this.toBBox); }
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
function findItem(item, items, equalsFn) {
|
|
525
|
+
if (!equalsFn) { return items.indexOf(item); }
|
|
526
|
+
|
|
527
|
+
for (var i = 0; i < items.length; i++) {
|
|
528
|
+
if (equalsFn(item, items[i])) { return i; }
|
|
529
|
+
}
|
|
530
|
+
return -1;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// calculate node's bbox from bboxes of its children
|
|
534
|
+
function calcBBox(node, toBBox) {
|
|
535
|
+
distBBox(node, 0, node.children.length, toBBox, node);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// min bounding rectangle of node children from k to p-1
|
|
539
|
+
function distBBox(node, k, p, toBBox, destNode) {
|
|
540
|
+
if (!destNode) { destNode = createNode(null); }
|
|
541
|
+
destNode.minX = Infinity;
|
|
542
|
+
destNode.minY = Infinity;
|
|
543
|
+
destNode.maxX = -Infinity;
|
|
544
|
+
destNode.maxY = -Infinity;
|
|
545
|
+
|
|
546
|
+
for (var i = k; i < p; i++) {
|
|
547
|
+
var child = node.children[i];
|
|
548
|
+
extend(destNode, node.leaf ? toBBox(child) : child);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
return destNode;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
function extend(a, b) {
|
|
555
|
+
a.minX = Math.min(a.minX, b.minX);
|
|
556
|
+
a.minY = Math.min(a.minY, b.minY);
|
|
557
|
+
a.maxX = Math.max(a.maxX, b.maxX);
|
|
558
|
+
a.maxY = Math.max(a.maxY, b.maxY);
|
|
559
|
+
return a;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function compareNodeMinX(a, b) { return a.minX - b.minX; }
|
|
563
|
+
function compareNodeMinY(a, b) { return a.minY - b.minY; }
|
|
564
|
+
|
|
565
|
+
function bboxArea(a) { return (a.maxX - a.minX) * (a.maxY - a.minY); }
|
|
566
|
+
function bboxMargin(a) { return (a.maxX - a.minX) + (a.maxY - a.minY); }
|
|
567
|
+
|
|
568
|
+
function enlargedArea(a, b) {
|
|
569
|
+
return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) *
|
|
570
|
+
(Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY));
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function intersectionArea(a, b) {
|
|
574
|
+
var minX = Math.max(a.minX, b.minX);
|
|
575
|
+
var minY = Math.max(a.minY, b.minY);
|
|
576
|
+
var maxX = Math.min(a.maxX, b.maxX);
|
|
577
|
+
var maxY = Math.min(a.maxY, b.maxY);
|
|
578
|
+
|
|
579
|
+
return Math.max(0, maxX - minX) *
|
|
580
|
+
Math.max(0, maxY - minY);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function contains(a, b) {
|
|
584
|
+
return a.minX <= b.minX &&
|
|
585
|
+
a.minY <= b.minY &&
|
|
586
|
+
b.maxX <= a.maxX &&
|
|
587
|
+
b.maxY <= a.maxY;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
function intersects(a, b) {
|
|
591
|
+
return b.minX <= a.maxX &&
|
|
592
|
+
b.minY <= a.maxY &&
|
|
593
|
+
b.maxX >= a.minX &&
|
|
594
|
+
b.maxY >= a.minY;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
function createNode(children) {
|
|
598
|
+
return {
|
|
599
|
+
children: children,
|
|
600
|
+
height: 1,
|
|
601
|
+
leaf: true,
|
|
602
|
+
minX: Infinity,
|
|
603
|
+
minY: Infinity,
|
|
604
|
+
maxX: -Infinity,
|
|
605
|
+
maxY: -Infinity
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// sort an array so that items come in groups of n unsorted items, with groups sorted between each other;
|
|
610
|
+
// combines selection algorithm with binary divide & conquer approach
|
|
611
|
+
|
|
612
|
+
function multiSelect(arr, left, right, n, compare) {
|
|
613
|
+
var stack = [left, right];
|
|
614
|
+
|
|
615
|
+
while (stack.length) {
|
|
616
|
+
right = stack.pop();
|
|
617
|
+
left = stack.pop();
|
|
618
|
+
|
|
619
|
+
if (right - left <= n) { continue; }
|
|
620
|
+
|
|
621
|
+
var mid = left + Math.ceil((right - left) / n / 2) * n;
|
|
622
|
+
quickselect(arr, mid, left, right, compare);
|
|
623
|
+
|
|
624
|
+
stack.push(left, mid, mid, right);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
export default RBush;
|
|
@@ -58,9 +58,9 @@ const getTransition = () => {
|
|
|
58
58
|
return transition;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
let centerWidth = props.contentWidth
|
|
61
|
+
let centerWidth = props.contentWidth > 0 ? props.contentWidth : 1; // 兼容处理,contentWidth变更为centerWidth
|
|
62
62
|
if (props.centerWidth >= 0) {
|
|
63
|
-
centerWidth = props.centerWidth;
|
|
63
|
+
centerWidth = props.centerWidth > 0 ? props.centerWidth : 1;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const imageDspWidthInner = computed(() =>
|