diff --git a/umap/static/umap/js/modules/slideshow.js b/umap/static/umap/js/modules/slideshow.js index 51b4a523..b6708f2c 100644 --- a/umap/static/umap/js/modules/slideshow.js +++ b/umap/static/umap/js/modules/slideshow.js @@ -18,13 +18,7 @@ export default class Slideshow extends WithTemplate { this.map = map this._id = null this.CLASSNAME = 'umap-slideshow-active' - this.options = Object.assign( - { - delay: 5000, - autoplay: false, - }, - options - ) + this.setOptions(options) this._current = null if (this.options.autoplay) { @@ -60,6 +54,16 @@ export default class Slideshow extends WithTemplate { return this.current.getNext() } + setOptions(options) { + this.options = Object.assign( + { + delay: 5000, + autoplay: false, + }, + options + ) + } + defaultDatalayer() { return this.map.findDataLayer((d) => d.canBrowse()) } diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 5a8d0af4..99afe89b 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -187,6 +187,7 @@ U.Map = L.Map.extend({ } this.initShortcuts() + if (!this.options.noControl) this.initCaptionBar() this.onceDataLoaded(this.setViewFromQueryString) window.onbeforeunload = () => (this.editEnabled && this.isDirty) || null @@ -303,7 +304,6 @@ U.Map = L.Map.extend({ setViewFromQueryString: async function () { if (this.options.noControl) return - this.initCaptionBar() if (L.Util.queryString('share')) { this.share.open() } else if (this.options.onLoadPanel === 'databrowser') { @@ -1469,12 +1469,8 @@ U.Map = L.Map.extend({ { handler: 'Switch', label: L._('Autostart when map is loaded') }, ], ] - const slideshowHandler = function () { - this.slideshow.setOptions(this.options.slideshow) - } const slideshowBuilder = new U.FormBuilder(this, slideshowFields, { - callback: slideshowHandler, - callbackContext: this, + callback: () => this.slideshow.setOptions(this.options.slideshow), }) slideshow.appendChild(slideshowBuilder.build()) },