pause/resume overlays
This commit is contained in:
parent
25e8ed6464
commit
4e730b9708
1 changed files with 42 additions and 4 deletions
|
@ -2545,6 +2545,10 @@ c3nav = {
|
||||||
c3nav.resume_level = c3nav._levelControl.currentLevel;
|
c3nav.resume_level = c3nav._levelControl.currentLevel;
|
||||||
c3nav._levelControl.setLevel(null);
|
c3nav._levelControl.setLevel(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c3nav._overlayControl) {
|
||||||
|
c3nav._overlayControl.pause();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_resume: function () {
|
_resume: function () {
|
||||||
if (c3nav._fetch_updates_timer === null) {
|
if (c3nav._fetch_updates_timer === null) {
|
||||||
|
@ -2564,6 +2568,10 @@ c3nav = {
|
||||||
console.info("c3nav._resume() -> scheduling searchable locations timeout: " + scheduled_load_in);
|
console.info("c3nav._resume() -> scheduling searchable locations timeout: " + scheduled_load_in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c3nav._overlayControl) {
|
||||||
|
c3nav._overlayControl.resume();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_visibility_hidden_timer: null,
|
_visibility_hidden_timer: null,
|
||||||
on_visibility_change: function () {
|
on_visibility_change: function () {
|
||||||
|
@ -3182,6 +3190,18 @@ OverlayControl = ExpandingControl.extend({
|
||||||
this._levels = levels;
|
this._levels = levels;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
pause: function () {
|
||||||
|
for (const overlay of Object.values(this._overlays)) {
|
||||||
|
overlay.pause();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
resume: function () {
|
||||||
|
for (const overlay of Object.values(this._overlays)) {
|
||||||
|
overlay.resume();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onAdd: function () {
|
onAdd: function () {
|
||||||
|
|
||||||
const initialActiveOverlays = this.getStored('active', []);
|
const initialActiveOverlays = this.getStored('active', []);
|
||||||
|
@ -3496,17 +3516,35 @@ class DataOverlay {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pause() {
|
||||||
|
if (this.fetch_timeout !== null) {
|
||||||
|
window.clearTimeout(this.fetch_timeout);
|
||||||
|
this.fetch_timeout = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resume() {
|
||||||
|
if (this.active && this.update_interval !== null) {
|
||||||
|
// noinspection JSIgnoredPromiseFromCall
|
||||||
|
this.fetch_features();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fetch_features() {
|
async fetch_features() {
|
||||||
if (this.fetch_timeout !== null) {
|
if (this.fetch_timeout !== null) {
|
||||||
window.clearTimeout(this.fetch_timeout);
|
window.clearTimeout(this.fetch_timeout);
|
||||||
this.fetch_timeout = null;
|
this.fetch_timeout = null;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
const {data: features, etag} = await c3nav_api.get_with_etag(`mapdata/dataoverlayfeatures/?overlay=${this.id}`, this.etag);
|
const {data: features, etag} = await c3nav_api.get_with_etag(`mapdata/dataoverlayfeatures/?overlay=${this.id}`, this.etag);
|
||||||
|
|
||||||
if (features !== null) {
|
if (features !== null) {
|
||||||
this.update_features(features);
|
this.update_features(features);
|
||||||
this.etag = etag;
|
this.etag = etag;
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.update_interval !== null && this.fetch_timeout === null) {
|
if (this.update_interval !== null && this.fetch_timeout === null) {
|
||||||
this.fetch_timeout = window.setTimeout(() => {
|
this.fetch_timeout = window.setTimeout(() => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue