Save
This commit is contained in:
@@ -830,21 +830,19 @@ class Elementor_Places_Map extends \Elementor\Widget_Base
|
||||
const bounds = new google.maps.LatLngBounds();
|
||||
const markers = [];
|
||||
|
||||
let selectedLocation = null;
|
||||
|
||||
locations.forEach(loc => {
|
||||
if (loc.position && loc.position.lat && loc.position.lng) {
|
||||
const marker = new google.maps.Marker({
|
||||
position: loc.position,
|
||||
map: map,
|
||||
title: loc.name,
|
||||
icon: loc.icon || undefined
|
||||
position: loc.position,
|
||||
map: map,
|
||||
title: loc.name,
|
||||
icon: loc.icon || undefined
|
||||
});
|
||||
|
||||
|
||||
marker.addListener("click", () => {
|
||||
const voivKey = Object.keys(voivodeships).find(k => voivodeships[k].id === loc.voivodeship.id);
|
||||
console.log(voivodeships);
|
||||
console.log(voivodeships[voivKey].name);
|
||||
|
||||
if (voivKey) {
|
||||
select.value = voivodeships[voivKey].name;
|
||||
renderList(voivodeships[voivKey].name);
|
||||
@@ -852,20 +850,23 @@ class Elementor_Places_Map extends \Elementor\Widget_Base
|
||||
setTimeout(() => {
|
||||
const itemEl = listContainer.querySelector(`.location-item[data-id="${loc.id}"]`);
|
||||
if (itemEl) {
|
||||
const itemRect = itemEl.getBoundingClientRect();
|
||||
const containerRect = listContainer.getBoundingClientRect();
|
||||
const offsetTop = itemRect.top - containerRect.top;
|
||||
console.log('itemRect.top: ', itemRect.top);
|
||||
console.log('containerRect.top: ', containerRect.top);
|
||||
console.log('offsetTop: ', offsetTop);
|
||||
const containerTop = listContainer.getBoundingClientRect().top;
|
||||
const itemTop = itemEl.getBoundingClientRect().top;
|
||||
const scrollOffset = listContainer.scrollTop + (itemTop - containerTop);
|
||||
|
||||
if (offsetTop != 0) {
|
||||
listContainer.scrollTo({
|
||||
top: offsetTop,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
if(loc.id == selectedLocation) {
|
||||
itemEl.classList.add('highlight');
|
||||
setTimeout(() => itemEl.classList.remove('highlight'), 1000);
|
||||
return;
|
||||
} else {
|
||||
selectedLocation = loc.id;
|
||||
}
|
||||
|
||||
listContainer.scrollTo({
|
||||
top: scrollOffset,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
|
||||
itemEl.classList.add('highlight');
|
||||
setTimeout(() => itemEl.classList.remove('highlight'), 1000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user