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);
|
this.initCallback(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
map.addEventListener("zoom", () => this.triggerCommand("refreshTouchBar"));
|
|
||||||
|
|
||||||
L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
|
L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
|
||||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
||||||
detectRetina: true
|
detectRetina: true
|
||||||
|
@ -105,6 +105,7 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
|||||||
private currentMarkerData: Record<string, Marker>;
|
private currentMarkerData: Record<string, Marker>;
|
||||||
private currentTrackData: Record<string, GPX>;
|
private currentTrackData: Record<string, GPX>;
|
||||||
private gpxLoaded?: boolean;
|
private gpxLoaded?: boolean;
|
||||||
|
private ignoreNextZoomEvent?: boolean;
|
||||||
|
|
||||||
static getType() {
|
static getType() {
|
||||||
return "geoMap";
|
return "geoMap";
|
||||||
@ -144,6 +145,13 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
|||||||
map.on("moveend", updateFn);
|
map.on("moveend", updateFn);
|
||||||
map.on("zoomend", updateFn);
|
map.on("zoomend", updateFn);
|
||||||
map.on("click", (e) => this.#onMapClicked(e));
|
map.on("click", (e) => this.#onMapClicked(e));
|
||||||
|
map.on("zoom", () => {
|
||||||
|
if (!this.ignoreNextZoomEvent) {
|
||||||
|
this.triggerCommand("refreshTouchBar");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ignoreNextZoomEvent = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async #restoreViewportAndZoom() {
|
async #restoreViewportAndZoom() {
|
||||||
@ -383,6 +391,7 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
|||||||
|
|
||||||
buildTouchBarCommand({ TouchBar }: CommandListenerData<"buildTouchBar">) {
|
buildTouchBarCommand({ TouchBar }: CommandListenerData<"buildTouchBar">) {
|
||||||
const map = this.geoMapWidget.map;
|
const map = this.geoMapWidget.map;
|
||||||
|
const that = this;
|
||||||
if (!map) {
|
if (!map) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -394,6 +403,7 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
|||||||
minValue: map.getMinZoom(),
|
minValue: map.getMinZoom(),
|
||||||
maxValue: map.getMaxZoom(),
|
maxValue: map.getMaxZoom(),
|
||||||
change(newValue) {
|
change(newValue) {
|
||||||
|
that.ignoreNextZoomEvent = true;
|
||||||
map.setZoom(newValue);
|
map.setZoom(newValue);
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user