homeflowjs 1.0.15 → 1.0.17
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.
@@ -187,7 +187,7 @@ export const postBulkPropertyExposureCreation = (payload) => () => {
|
|
187
187
|
export const loadNext = () => (dispatch, getState) => {
|
188
188
|
dispatch(setLoading({ properties: true }));
|
189
189
|
// set page on search to page + 1
|
190
|
-
let newProperties = [...getState().properties
|
190
|
+
let newProperties = [...getState().properties?.properties];
|
191
191
|
const nextPageSearch = { ...getState().search.initialSearch };
|
192
192
|
const currentPageNumber = getState()?.properties?.pagination?.current_page;
|
193
193
|
const branch = Homeflow.get('branch');
|
package/hooks/index.js
CHANGED
@@ -6,6 +6,7 @@ import usePropertyInfiniteScroll from './use-property-inifinite-scroll';
|
|
6
6
|
import useLoadBranches from './use-load-branches';
|
7
7
|
import useLoadPreviousProperties from './use-load-previous-properties';
|
8
8
|
import useRecaptcha from './use-recaptcha';
|
9
|
+
import useScrollTo from './use-scroll-to.hook';
|
9
10
|
|
10
11
|
export {
|
11
12
|
useDefaultSort,
|
@@ -15,5 +16,6 @@ export {
|
|
15
16
|
usePropertyInfiniteScroll,
|
16
17
|
useLoadBranches,
|
17
18
|
useLoadPreviousProperties,
|
18
|
-
useRecaptcha
|
19
|
+
useRecaptcha,
|
20
|
+
useScrollTo,
|
19
21
|
};
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { useEffect } from 'react';
|
2
|
+
import { isFunction } from '../utils';
|
3
|
+
|
4
|
+
const scrollToTarget = (target, { yOffset = 0 } = {}) => {
|
5
|
+
// If target is chunk ID
|
6
|
+
let targetElement;
|
7
|
+
if (!isNaN(target)) {
|
8
|
+
targetElement = document.querySelector(
|
9
|
+
`[data-content-id="${target}"]`,
|
10
|
+
);
|
11
|
+
}
|
12
|
+
|
13
|
+
// Check for ID or class name
|
14
|
+
if (!targetElement) targetElement = document.querySelector(`.${target}`);
|
15
|
+
if (!targetElement) targetElement = document.querySelector(`#${target}`);
|
16
|
+
|
17
|
+
if (targetElement) {
|
18
|
+
let verticalOffset = 0;
|
19
|
+
if (typeof yOffset === 'number') {
|
20
|
+
verticalOffset = yOffset;
|
21
|
+
} else if (isFunction(yOffset)) {
|
22
|
+
const value = yOffset();
|
23
|
+
if (typeof value === 'number') {
|
24
|
+
verticalOffset = value;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
const y = targetElement.getBoundingClientRect().top
|
29
|
+
+ window.pageYOffset + verticalOffset;
|
30
|
+
|
31
|
+
window.scrollTo({ top: y, behavior: 'smooth' });
|
32
|
+
history.scrollRestoration = 'manual';
|
33
|
+
}
|
34
|
+
};
|
35
|
+
|
36
|
+
const getTarget = (hash) => {
|
37
|
+
const [, search] = hash.split('?');
|
38
|
+
const { target } = Object.fromEntries(new URLSearchParams(search));
|
39
|
+
return target;
|
40
|
+
};
|
41
|
+
|
42
|
+
function handleScrollToClick(options) {
|
43
|
+
// eslint-disable-next-line func-names
|
44
|
+
return function () {
|
45
|
+
const target = getTarget(this.hash);
|
46
|
+
if (target) {
|
47
|
+
scrollToTarget(target, options);
|
48
|
+
}
|
49
|
+
};
|
50
|
+
}
|
51
|
+
|
52
|
+
const useScrollTo = (options) => {
|
53
|
+
useEffect(() => {
|
54
|
+
const scrollToEls = document.querySelectorAll('[href^="#scroll-to"]');
|
55
|
+
scrollToEls.forEach((el) => {
|
56
|
+
el.addEventListener(
|
57
|
+
'click',
|
58
|
+
handleScrollToClick(options),
|
59
|
+
);
|
60
|
+
});
|
61
|
+
|
62
|
+
const target = getTarget(window.location.hash);
|
63
|
+
scrollToTarget(target, options);
|
64
|
+
}, []);
|
65
|
+
};
|
66
|
+
|
67
|
+
export default useScrollTo;
|
package/package.json
CHANGED
@@ -449,6 +449,9 @@ export default class DraggableMap {
|
|
449
449
|
|
450
450
|
buildPolygon() {
|
451
451
|
const search = this.getSearch();
|
452
|
+
const place = Homeflow.get('place');
|
453
|
+
const placeObjectAllValuesNullOrEmpty = place ? Object.values(place)?.every(value => value === null || value === '') : true;
|
454
|
+
|
452
455
|
if (Homeflow.get('enable_draw_a_map') && (search.poly != null)) {
|
453
456
|
const polygon = new L.Polygon.fromEncoded(search.poly);
|
454
457
|
const polygonBounds = polygon.getBounds();
|
@@ -460,9 +463,8 @@ export default class DraggableMap {
|
|
460
463
|
});
|
461
464
|
return this.map.fitBounds(polygonBounds);
|
462
465
|
|
463
|
-
} else if (
|
466
|
+
} else if (place != null && !placeObjectAllValuesNullOrEmpty) {
|
464
467
|
let center;
|
465
|
-
const place = Homeflow.get('place');
|
466
468
|
if (search.expandedPolygon && Homeflow.get('enable_polygon_radius_search')) {
|
467
469
|
const expandedStyle = { weight: 2, dashArray: "8 8", color: '#000' }
|
468
470
|
if (place.polygon.length === 1) this.buildSubPolygons(place.polygon);
|
package/utils/index.js
CHANGED
@@ -153,3 +153,7 @@ export function JSON_to_URLEncoded(element,key,list){
|
|
153
153
|
}
|
154
154
|
return encodeURI(list.join('&'));
|
155
155
|
}
|
156
|
+
|
157
|
+
export function isFunction(functionToCheck) {
|
158
|
+
return functionToCheck && Object.prototype.toString.call(functionToCheck) === '[object Function]';
|
159
|
+
}
|