homeflowjs 1.0.65 → 1.0.66

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": "homeflowjs",
3
- "version": "1.0.65",
3
+ "version": "1.0.66",
4
4
  "sideEffects": [
5
5
  "modal/**/*",
6
6
  "user/default-profile/**/*",
@@ -93,7 +93,33 @@ export default class DraggableMap {
93
93
  // is a design feature
94
94
  this.initControlsMobile();
95
95
  }
96
- if (this.noLocationfound) { this.setToMarkeredBounds(); }
96
+
97
+ if (this.noLocationfound) {
98
+ /**
99
+ * If no location is found but if properties
100
+ * are found (i.e search without a location)
101
+ * run the setToMarkeredBounds
102
+ */
103
+ const properties = this.getProperties();
104
+ if(properties) this.setToMarkeredBounds();
105
+
106
+ /**
107
+ * If no location and properties are found, the setToMarkeredBounds
108
+ * will return null as it can't find any bounds. In turn
109
+ * this causes the map to error because it can't set a center point.
110
+ * If this is case, we need to grab the last center point and zoom
111
+ * from the last drag event and use that to set the map view.
112
+ *
113
+ * (properties are not found if the map
114
+ * re-renders because of a parent component and
115
+ * the user has dragged out of site of any properties)
116
+ */
117
+ const lastDragEvent = Homeflow.get('last_map_drag_event');
118
+ if(!properties) {
119
+ this.map.setView(lastDragEvent.center, lastDragEvent.zoom);
120
+ }
121
+ }
122
+
97
123
  if (Homeflow.get('custom_map_zoom')) {
98
124
  this.map.setZoom(Homeflow.get('custom_map_zoom'));
99
125
  }
@@ -508,6 +534,14 @@ export default class DraggableMap {
508
534
  // no drag allowed.
509
535
  if (Homeflow.get('disable_draggable_map') || this.drawableMapInitialized) return;
510
536
 
537
+ // Acts as a fallback in the init if the map is re-rendered without any properties
538
+ const center = this.map.getCenter();
539
+ const zoom = this.map.getZoom();
540
+ Homeflow.set('last_map_drag_event', {
541
+ center,
542
+ zoom
543
+ })
544
+
511
545
  // drag map but no fetching properties within the new boundaries.
512
546
  if(this.dragWithoutUpdate) return null;
513
547