|
@@ -331,12 +331,38 @@ export class PointerTracker implements Tracker
|
331
|
331
|
return {
|
332
|
332
|
exports: {
|
333
|
333
|
tracker: this,
|
334
|
|
- trackables: trackables
|
|
334
|
+ trackables: this._sortTrackables(trackables)
|
335
|
335
|
}
|
336
|
336
|
};
|
337
|
337
|
}
|
338
|
338
|
|
339
|
339
|
/**
|
|
340
|
+ * As a convenience, let's make sure that a primary pointer, if any exists,
|
|
341
|
+ * is at the beginning of the trackables array
|
|
342
|
+ * @param trackables
|
|
343
|
+ * @returns sorted trackables
|
|
344
|
+ */
|
|
345
|
+ private _sortTrackables(trackables: TrackablePointer[]): TrackablePointer[]
|
|
346
|
+ {
|
|
347
|
+ // nothing to do
|
|
348
|
+ if(trackables.length <= 1 || trackables[0].isPrimary)
|
|
349
|
+ return trackables;
|
|
350
|
+
|
|
351
|
+ // find a primary pointer and swap
|
|
352
|
+ for(let j = 1; j < trackables.length; j++) {
|
|
353
|
+ if(trackables[j].isPrimary) {
|
|
354
|
+ const primary = trackables[j];
|
|
355
|
+ trackables[j] = trackables[0];
|
|
356
|
+ trackables[0] = primary;
|
|
357
|
+ break;
|
|
358
|
+ }
|
|
359
|
+ }
|
|
360
|
+
|
|
361
|
+ // done!
|
|
362
|
+ return trackables;
|
|
363
|
+ }
|
|
364
|
+
|
|
365
|
+ /**
|
340
|
366
|
* Find trackables to remove
|
341
|
367
|
* @returns a list of trackables to remove
|
342
|
368
|
*/
|