Fix hover events on message (feed)

This commit is contained in:
2026-01-17 00:57:07 +01:00
parent e70d3ddbd3
commit 4f3be3342c
2 changed files with 34 additions and 26 deletions

View File

@@ -46,7 +46,7 @@ export default {
colors:{'main':'#00ff78', 'off-track':'#0000ff', 'hitchhiking':'#FF7814'}, colors:{'main':'#00ff78', 'off-track':'#0000ff', 'hitchhiking':'#FF7814'},
width: 4 width: 4
}, },
popup: null popup: {content: null, element: null}
}; };
}, },
computed: { computed: {
@@ -86,8 +86,10 @@ export default {
provide() { provide() {
return { return {
map: { map: {
panTo: this.panTo, panToBetweenPanels: this.panToBetweenPanels,
openMarkerPopup: this.openMarkerPopup openMarkerPopup: this.openMarkerPopup,
closeMarkerPopup: this.closeMarkerPopup,
isMarkerVisible: this.isMarkerVisible
}, },
project: { project: {
...this.$data, ...this.$data,
@@ -310,10 +312,7 @@ export default {
//Legend //Legend
}, },
openMarkerPopup(oFeature) { openMarkerPopup(oFeature) {
if(this.popup) { this.closeMarkerPopup();
this.popup.unmount();
this.popup = null;
}
//Convert ID Message to feature //Convert ID Message to feature
if(typeof oFeature == 'number') { if(typeof oFeature == 'number') {
@@ -329,7 +328,7 @@ export default {
} }
const $Popup = document.createElement('div'); const $Popup = document.createElement('div');
const oPopup = new Popup({ this.popup.element = new Popup({
anchor: 'bottom', anchor: 'bottom',
offset: [0, this.markerSize.height * -1], offset: [0, this.markerSize.height * -1],
closeButton: false closeButton: false
@@ -355,11 +354,21 @@ export default {
}); });
nextTick(() => { nextTick(() => {
this.popup = createApp(vPopup); this.popup.content = createApp(vPopup);
this.popup.mount($Popup); this.popup.content.mount($Popup);
}); });
}, },
panTo(oLngLat, iZoom, fCallback) { closeMarkerPopup() {
if(this.popup.content) {
this.popup.content.unmount();
this.popup.content = null;
}
if(this.popup.element) {
this.popup.element.remove();
this.popup.element = null;
}
},
panToBetweenPanels(oLngLat, iZoom, fCallback) {
const iXOffset = (this.settingsPanelOpen?getOuterWidth(this.$refs.settings):0) - (this.feedPanelOpen?getOuterWidth(this.$refs.feed):0); const iXOffset = (this.settingsPanelOpen?getOuterWidth(this.$refs.settings):0) - (this.feedPanelOpen?getOuterWidth(this.$refs.feed):0);
this.map.easeTo({ this.map.easeTo({
center: oLngLat, center: oLngLat,
@@ -369,6 +378,9 @@ export default {
}); });
setTimeout(fCallback, 500); setTimeout(fCallback, 500);
}, },
isMarkerVisible(oLngLat){
return this.map.getBounds().contains(oLngLat);
},
getGoogleMapsLink(asInfo) { getGoogleMapsLink(asInfo) {
return $('<a>', { return $('<a>', {
href:'https://www.google.com/maps/place/'+asInfo.lat_dms+'+'+asInfo.lon_dms+'/@'+asInfo.latitude+','+asInfo.longitude+',10z', href:'https://www.google.com/maps/place/'+asInfo.lat_dms+'+'+asInfo.lon_dms+'/@'+asInfo.latitude+','+asInfo.longitude+',10z',

View File

@@ -27,7 +27,8 @@
timeDiff: (this.options.formatted_time && this.options.formatted_time_local != this.options.formatted_time), timeDiff: (this.options.formatted_time && this.options.formatted_time_local != this.options.formatted_time),
anchorVisible: ['message', 'media', 'post'].includes(this.options.type), anchorVisible: ['message', 'media', 'post'].includes(this.options.type),
anchorTitle: this.spot.lang('copy_to_clipboard'), anchorTitle: this.spot.lang('copy_to_clipboard'),
anchorIcon: 'link' anchorIcon: 'link',
popupRequested: false
}; };
}, },
computed: { computed: {
@@ -54,6 +55,9 @@
relTime() { relTime() {
return this.modeHisto?(this.options.formatted_time || '').substr(0, 10):this.options.relative_time; return this.modeHisto?(this.options.formatted_time || '').substr(0, 10):this.options.relative_time;
}, },
lngLat() {
return (this.options.type == 'message')?(new LngLat(this.options.longitude, this.options.latitude)):null;
}
}, },
inject: ['spot', 'project', 'user', 'map', 'project'], inject: ['spot', 'project', 'user', 'map', 'project'],
@@ -68,28 +72,20 @@
}, 5000); }, 5000);
}, },
panMapToMessage() { panMapToMessage() {
this.popupRequested = true;
if(this.spot.isMobile()) this.project.toggleFeedPanel(false, 'panToInstant'); if(this.spot.isMobile()) this.project.toggleFeedPanel(false, 'panToInstant');
this.map.panTo( this.map.panToBetweenPanels(
new LngLat(this.options.longitude, this.options.latitude), this.lngLat,
15, 15,
() => {this.map.openMarkerPopup(this.options.id_message);} () => {this.map.openMarkerPopup(this.options.id_message);}
); );
}, },
openMarkerPopup() { openMarkerPopup() {
//TODO if(this.map.isMarkerVisible(this.lngLat)) this.map.openMarkerPopup(this.options.id_message);
/*
let oMarker = this.spot.tmp(['markers', $(oEvent.currentTarget).data('id')]);
if(this.spot.tmp('map') && this.spot.tmp('map').getBounds().contains(oMarker.getLatLng()) && !oMarker.isPopupOpen()) oMarker.openPopup();
*/
}, },
closeMarkerPopup() { closeMarkerPopup() {
//TODO if(!this.popupRequested) this.map.closeMarkerPopup();
/* this.popupRequested = false;
let $This = $(oEvent.currentTarget);
let oMarker = this.spot.tmp(['markers', $This.data('id')]);
if(oMarker && oMarker.isPopupOpen() && !$This.data('clicked')) oMarker.closePopup();
$This.data('clicked', false);
*/
} }
}, },
mounted() { mounted() {