mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
better touch hinting
This commit is contained in:
parent
328d2665fa
commit
9000efddad
3 changed files with 58 additions and 28 deletions
|
@ -38,15 +38,19 @@ export class Component extends Polyline {
|
||||||
this.constrLine = new Polyline([], this.constraintsStyle);
|
this.constrLine = new Polyline([], this.constraintsStyle);
|
||||||
|
|
||||||
this.startDragHinting();
|
this.startDragHinting();
|
||||||
this.touchHinter.on('click', console.log);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTouchHinter = ({ latlngs }: { latlngs: LatLngLiteral[] }): void => {
|
||||||
|
this.touchHinter.setLatLngs(latlngs);
|
||||||
|
};
|
||||||
|
|
||||||
setPoints = (latlngs: LatLng[]) => {
|
setPoints = (latlngs: LatLng[]) => {
|
||||||
this.setLatLngs(latlngs);
|
this.setLatLngs(latlngs);
|
||||||
this.recreateMarkers();
|
this.recreateMarkers();
|
||||||
this.recalcDistance();
|
this.recalcDistance();
|
||||||
this.recalcKmMarks();
|
this.recalcKmMarks();
|
||||||
this.touchHinter.setLatLngs(latlngs);
|
this.touchHinter.setLatLngs(latlngs);
|
||||||
|
this.fire('latlngschange', { latlngs });
|
||||||
};
|
};
|
||||||
|
|
||||||
createHintMarker = (latlng: LatLng): Marker => marker(latlng, {
|
createHintMarker = (latlng: LatLng): Marker => marker(latlng, {
|
||||||
|
@ -365,7 +369,10 @@ export class Component extends Polyline {
|
||||||
this.setConstraints([latlng, marker.getLatLng()]);
|
this.setConstraints([latlng, marker.getLatLng()]);
|
||||||
};
|
};
|
||||||
|
|
||||||
onDrawingClick = ({ latlng }: LeafletMouseEvent): void => {
|
onDrawingClick = (event: LeafletMouseEvent): void => {
|
||||||
|
console.log(event);
|
||||||
|
const { latlng } = event;
|
||||||
|
|
||||||
this.stopDrawing();
|
this.stopDrawing();
|
||||||
const latlngs = this.getLatLngs() as any[];
|
const latlngs = this.getLatLngs() as any[];
|
||||||
|
|
||||||
|
@ -378,8 +385,9 @@ export class Component extends Polyline {
|
||||||
latlngs.unshift(latlng);
|
latlngs.unshift(latlng);
|
||||||
this.markers.unshift(this.createMarker(latlng));
|
this.markers.unshift(this.createMarker(latlng));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setLatLngs(latlngs);
|
this.setLatLngs(latlngs);
|
||||||
this.touchHinter.setLatLngs(latlngs);
|
this.fire('latlngschange', { latlngs });
|
||||||
this.startDrawing();
|
this.startDrawing();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -403,15 +411,15 @@ export class Component extends Polyline {
|
||||||
replaceLatlng = (latlng: LatLng, index: number): void => {
|
replaceLatlng = (latlng: LatLng, index: number): void => {
|
||||||
const latlngs = this.getLatLngs() as LatLngLiteral[];
|
const latlngs = this.getLatLngs() as LatLngLiteral[];
|
||||||
latlngs.splice(index, 1, latlng);
|
latlngs.splice(index, 1, latlng);
|
||||||
this.touchHinter.setLatLngs(latlngs);
|
|
||||||
this.setLatLngs(latlngs);
|
this.setLatLngs(latlngs);
|
||||||
|
this.fire('latlngschange', { latlngs });
|
||||||
};
|
};
|
||||||
|
|
||||||
insertLatLng = (latlng, index): void => {
|
insertLatLng = (latlng, index): void => {
|
||||||
const latlngs = this.getLatLngs();
|
const latlngs = this.getLatLngs();
|
||||||
latlngs.splice(index, 0, latlng);
|
latlngs.splice(index, 0, latlng);
|
||||||
this.touchHinter.setLatLngs(latlngs);
|
|
||||||
this.setLatLngs(latlngs);
|
this.setLatLngs(latlngs);
|
||||||
|
this.fire('latlngschange', { latlngs });
|
||||||
};
|
};
|
||||||
|
|
||||||
setConstraints = (coords: LatLng[]) => {
|
setConstraints = (coords: LatLng[]) => {
|
||||||
|
@ -430,7 +438,7 @@ export class Component extends Polyline {
|
||||||
latlngs.splice(index, 1);
|
latlngs.splice(index, 1);
|
||||||
|
|
||||||
this.setLatLngs(latlngs);
|
this.setLatLngs(latlngs);
|
||||||
this.touchHinter.setLatLngs(latlngs);
|
this.fire('latlngschange', { latlngs });
|
||||||
};
|
};
|
||||||
|
|
||||||
dropMarkerDistanceChange = (index: number): void => {
|
dropMarkerDistanceChange = (index: number): void => {
|
||||||
|
@ -482,8 +490,6 @@ export class Component extends Polyline {
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
console.log('counting km marks', this.kmMarks);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
kmMarksEnabled?: InteractivePolylineOptions['kmMarksEnabled'] = true;
|
kmMarksEnabled?: InteractivePolylineOptions['kmMarksEnabled'] = true;
|
||||||
|
@ -502,7 +508,12 @@ export class Component extends Polyline {
|
||||||
opacity: 0.5,
|
opacity: 0.5,
|
||||||
};
|
};
|
||||||
|
|
||||||
touchHinter: Polyline = new Polyline([], { weight: 25, color: 'rgba(255, 255, 255, 0.7)' });
|
touchHinter: Polyline = new Polyline([], {
|
||||||
|
weight: 25,
|
||||||
|
color: 'rgba(255, 255, 255, 0)',
|
||||||
|
smoothFactor: 3,
|
||||||
|
// bubblingMouseEvents: false,
|
||||||
|
});
|
||||||
hintMarker: Marker = this.createHintMarker(latLng({ lat: 0, lng: 0 }));
|
hintMarker: Marker = this.createHintMarker(latLng({ lat: 0, lng: 0 }));
|
||||||
|
|
||||||
constrLine: Polyline;
|
constrLine: Polyline;
|
||||||
|
@ -532,6 +543,8 @@ Component.addInitHook(function () {
|
||||||
|
|
||||||
this.map.on('moveend', this.updateMarkers);
|
this.map.on('moveend', this.updateMarkers);
|
||||||
|
|
||||||
|
this.on('latlngschange', this.updateTouchHinter);
|
||||||
|
|
||||||
if (window.innerWidth < 768) {
|
if (window.innerWidth < 768) {
|
||||||
this.touchHinter.setStyle({ weight: 50 });
|
this.touchHinter.setStyle({ weight: 50 });
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ export class Poly {
|
||||||
weight: 6,
|
weight: 6,
|
||||||
maxMarkers: 100,
|
maxMarkers: 100,
|
||||||
smoothFactor: 3,
|
smoothFactor: 3,
|
||||||
bubblingMouseEvents: false,
|
// bubblingMouseEvents: false,
|
||||||
})
|
})
|
||||||
.on('distancechange', this.onDistanceUpdate);
|
.on('distancechange', this.onDistanceUpdate);
|
||||||
|
|
||||||
|
|
|
@ -26,32 +26,49 @@
|
||||||
.leaflet-vertex-icon, .leaflet-middle-icon {
|
.leaflet-vertex-icon, .leaflet-middle-icon {
|
||||||
outline: none !important;
|
outline: none !important;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
opacity :1;
|
opacity: 1;
|
||||||
border: none;
|
border: none;
|
||||||
width: 16px !important;
|
width: 16px !important;
|
||||||
height: 16px !important;margin-left:-8px !important;margin-top:-8px !important;
|
height: 16px !important;margin-left:-8px !important;margin-top:-8px !important;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
position: absolute;
|
||||||
|
|
||||||
.leaflet-middle-icon {
|
&::before {
|
||||||
opacity: 0.5;
|
width: 24px;
|
||||||
}
|
height: 24px;
|
||||||
|
background: none;
|
||||||
|
content: ' ';
|
||||||
|
position: absolute;
|
||||||
|
transform: translate(-4px, -4px);
|
||||||
|
border-radius: 16px;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.leaflet-vertex-icon::after, .leaflet-middle-icon::after {
|
@media (max-width: @mobile_breakpoint) {
|
||||||
content: ' ';
|
&::before {
|
||||||
position:absolute;top:4px;left:4px;width:8px;height:8px;
|
width: 32px;
|
||||||
background:white;border-radius: 8px;transform:scale(1);
|
height: 32px;
|
||||||
transition:transform 150ms;
|
transform: translate(-8px, -8px);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.leaflet-vertex-icon:hover, .leaflet-middle-icon:hover {
|
&::after {
|
||||||
opacity: 1 !important;
|
content: ' ';
|
||||||
}
|
position:absolute;
|
||||||
|
top:4px;
|
||||||
|
left:4px;
|
||||||
|
width:8px;
|
||||||
|
height:8px;
|
||||||
|
background:white;
|
||||||
|
border-radius: 8px;
|
||||||
|
transform:scale(1);
|
||||||
|
transition:transform 150ms;
|
||||||
|
}
|
||||||
|
|
||||||
.leaflet-vertex-icon:hover::after, .leaflet-middle-icon:hover::after,
|
&:hover {
|
||||||
.leaflet-vertex-icon:active::after, .leaflet-middle-icon:active::after {
|
opacity: 1;
|
||||||
transform: scale(2);
|
}
|
||||||
box-shadow: #999 0 0 5px 2px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.leaflet-control-container .leaflet-routing-container-hide {
|
.leaflet-control-container .leaflet-routing-container-hide {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue