mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-01 04:12:58 +08:00
fix(touch_bar): jerkiness when zooming
This commit is contained in:
parent
323f42873f
commit
cbbe10ba67
@ -52,8 +52,6 @@ export default class GeoMapWidget extends NoteContextAwareWidget {
|
||||
this.initCallback(L);
|
||||
}
|
||||
|
||||
map.addEventListener("zoom", () => this.triggerCommand("refreshTouchBar"));
|
||||
|
||||
L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
||||
detectRetina: true
|
||||
|
@ -105,6 +105,7 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
||||
private currentMarkerData: Record<string, Marker>;
|
||||
private currentTrackData: Record<string, GPX>;
|
||||
private gpxLoaded?: boolean;
|
||||
private ignoreNextZoomEvent?: boolean;
|
||||
|
||||
static getType() {
|
||||
return "geoMap";
|
||||
@ -144,6 +145,13 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
||||
map.on("moveend", updateFn);
|
||||
map.on("zoomend", updateFn);
|
||||
map.on("click", (e) => this.#onMapClicked(e));
|
||||
map.on("zoom", () => {
|
||||
if (!this.ignoreNextZoomEvent) {
|
||||
this.triggerCommand("refreshTouchBar");
|
||||
}
|
||||
|
||||
this.ignoreNextZoomEvent = false;
|
||||
});
|
||||
}
|
||||
|
||||
async #restoreViewportAndZoom() {
|
||||
@ -383,6 +391,7 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
||||
|
||||
buildTouchBarCommand({ TouchBar }: CommandListenerData<"buildTouchBar">) {
|
||||
const map = this.geoMapWidget.map;
|
||||
const that = this;
|
||||
if (!map) {
|
||||
return;
|
||||
}
|
||||
@ -394,6 +403,7 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
||||
minValue: map.getMinZoom(),
|
||||
maxValue: map.getMaxZoom(),
|
||||
change(newValue) {
|
||||
that.ignoreNextZoomEvent = true;
|
||||
map.setZoom(newValue);
|
||||
},
|
||||
}),
|
||||
|
Loading…
x
Reference in New Issue
Block a user