Merge pull request #1992 from umap-project/slideshow-fixes

Fix up following move of slideshow class to modules
This commit is contained in:
David Larlet 2024-07-12 12:06:04 -04:00 committed by GitHub
commit 3e20aff674
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 13 deletions

View file

@ -18,13 +18,7 @@ export default class Slideshow extends WithTemplate {
this.map = map this.map = map
this._id = null this._id = null
this.CLASSNAME = 'umap-slideshow-active' this.CLASSNAME = 'umap-slideshow-active'
this.options = Object.assign( this.setOptions(options)
{
delay: 5000,
autoplay: false,
},
options
)
this._current = null this._current = null
if (this.options.autoplay) { if (this.options.autoplay) {
@ -60,6 +54,16 @@ export default class Slideshow extends WithTemplate {
return this.current.getNext() return this.current.getNext()
} }
setOptions(options) {
this.options = Object.assign(
{
delay: 5000,
autoplay: false,
},
options
)
}
defaultDatalayer() { defaultDatalayer() {
return this.map.findDataLayer((d) => d.canBrowse()) return this.map.findDataLayer((d) => d.canBrowse())
} }

View file

@ -187,6 +187,7 @@ U.Map = L.Map.extend({
} }
this.initShortcuts() this.initShortcuts()
if (!this.options.noControl) this.initCaptionBar()
this.onceDataLoaded(this.setViewFromQueryString) this.onceDataLoaded(this.setViewFromQueryString)
window.onbeforeunload = () => (this.editEnabled && this.isDirty) || null window.onbeforeunload = () => (this.editEnabled && this.isDirty) || null
@ -303,7 +304,6 @@ U.Map = L.Map.extend({
setViewFromQueryString: async function () { setViewFromQueryString: async function () {
if (this.options.noControl) return if (this.options.noControl) return
this.initCaptionBar()
if (L.Util.queryString('share')) { if (L.Util.queryString('share')) {
this.share.open() this.share.open()
} else if (this.options.onLoadPanel === 'databrowser') { } else if (this.options.onLoadPanel === 'databrowser') {
@ -1469,12 +1469,8 @@ U.Map = L.Map.extend({
{ handler: 'Switch', label: L._('Autostart when map is loaded') }, { 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, { const slideshowBuilder = new U.FormBuilder(this, slideshowFields, {
callback: slideshowHandler, callback: () => this.slideshow.setOptions(this.options.slideshow),
callbackContext: this,
}) })
slideshow.appendChild(slideshowBuilder.build()) slideshow.appendChild(slideshowBuilder.build())
}, },