@yuneta/gobj-ui 1.0.1 → 1.0.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
package/src/c_yui_map.js CHANGED
@@ -776,10 +776,24 @@ function ac_refresh(gobj, event, kw, src)
776
776
  let devices = gobj_read_attr(gobj, "devices");
777
777
 
778
778
  let map = priv.xmap;
779
- if (map.isStyleLoaded()) {
780
- const geojson_data = devices2geojson(gobj, devices);
781
- map.getSource('devices').setData(geojson_data);
779
+
780
+ /*
781
+ * Ask for the source, do not infer it from the style. 'devices' is added
782
+ * by load_devices() on the map 'load' event, which is a LATER milestone:
783
+ * isStyleLoaded() is already true one render frame before 'load' fires,
784
+ * and getSource() is undefined in that frame. Nothing is lost by
785
+ * skipping, load_devices() reads the same attr.
786
+ *
787
+ * Testing the style was also wrong the other way: it goes back to false
788
+ * while new tiles load, so every refresh during a pan or a zoom was
789
+ * silently dropped and the devices stopped moving.
790
+ */
791
+ const source = map.getSource('devices');
792
+ if(!source) {
793
+ return 0;
782
794
  }
795
+
796
+ source.setData(devices2geojson(gobj, devices));
783
797
  return 0;
784
798
  }
785
799