mobility-toolbox-js 3.0.1-beta.9 → 3.1.0-beta.1

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.
@@ -142,6 +142,7 @@ declare class RealtimeLayer extends Layer {
142
142
  */
143
143
  highlightTrajectory(id: RealtimeTrainId): Promise<Feature[] | undefined>;
144
144
  onMoveEnd(): void;
145
+ onRealtimeEngineIdle(): void;
145
146
  /**
146
147
  * Callback when the RealtimeEngine has rendered successfully.
147
148
  */
@@ -106,7 +106,7 @@ class RealtimeLayer extends Layer {
106
106
  this.olEventsKeys = [];
107
107
  // For backward compatibility with v2
108
108
  defineDeprecatedProperties(this, options);
109
- this.engine = new RealtimeEngine(Object.assign({ getViewState: this.getViewState.bind(this), onRender: this.onRealtimeEngineRender.bind(this) }, options));
109
+ this.engine = new RealtimeEngine(Object.assign({ getViewState: this.getViewState.bind(this), onIdle: this.onRealtimeEngineIdle.bind(this), onRender: this.onRealtimeEngineRender.bind(this) }, options));
110
110
  this.allowRenderWhenAnimating = !!options.allowRenderWhenAnimating;
111
111
  // We store the layer used to highlight the full Trajectory
112
112
  this.vectorLayer = new VectorLayer({
@@ -128,7 +128,11 @@ class RealtimeLayer extends Layer {
128
128
  if (this.getVisible()) {
129
129
  this.engine.start();
130
130
  }
131
- this.olEventsKeys.push(...mapInternal.on(['moveend', 'change:target'],
131
+ this.olEventsKeys.push(mapInternal.on('movestart', () => {
132
+ if (this.engine.isUpdateBboxOnMoveEnd) {
133
+ this.engine.updateIdleState();
134
+ }
135
+ }), ...mapInternal.on(['moveend', 'change:target'],
132
136
  // @ts-expect-error - bad ol definitions
133
137
  (evt) => {
134
138
  const view = (evt.map || evt.target).getView();
@@ -304,6 +308,9 @@ class RealtimeLayer extends Layer {
304
308
  }
305
309
  this.engine.setBbox();
306
310
  }
311
+ onRealtimeEngineIdle() {
312
+ this.changed();
313
+ }
307
314
  /**
308
315
  * Callback when the RealtimeEngine has rendered successfully.
309
316
  */
@@ -55,8 +55,10 @@ export default class RealtimeLayerRenderer extends CanvasLayerRenderer {
55
55
  return true;
56
56
  }
57
57
  renderFrame(frameState) {
58
- const { canvas, renderedViewState } = this.getLayer();
58
+ var _a;
59
+ const { canvas, engine, renderedViewState } = this.getLayer();
59
60
  this.getLayer().engine.pixelRatio = frameState.pixelRatio;
61
+ this.ready = !!((_a = engine.renderState) === null || _a === void 0 ? void 0 : _a.renderedTrajectories) && engine.isIdle;
60
62
  if (!this.container) {
61
63
  this.container = document.createElement('div');
62
64
  this.container.className = this.getLayer().getClassName();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mobility-toolbox-js",
3
3
  "license": "MIT",
4
4
  "description": "Toolbox for JavaScript applications in the domains of mobility and logistics.",
5
- "version": "3.0.1-beta.9",
5
+ "version": "3.1.0-beta.1",
6
6
  "homepage": "https://mobility-toolbox-js.geops.io/",
7
7
  "exports": {
8
8
  ".": "./index.js",