Skip to content

Commit

Permalink
setControlTitle submodule extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
Stassi committed Nov 14, 2024
1 parent 1f6b17a commit 3d25705
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
17 changes: 11 additions & 6 deletions public/leaflet-fullscreen/fullscreen-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '../leaflet/leaflet-src.esm.js'

import { joinClassNames } from './join-class-names.js'
import { setControlTitle } from './set-control-title.js'
import { useBoolean } from './use-boolean.js'
import { useLink } from './use-link.js'

Expand Down Expand Up @@ -47,10 +48,6 @@ export function fullscreenMap({
control = leafletControl({ position }),
map = leafletMap(id, mapOptions)

function setControlTitle(fullscreen) {
linkAssign({ title: title[fullscreen] })
}

function mapLifecycleListener(documentFirstReady) {
return function handleFullscreenMapLifecycleEvent() {
DomEvent[documentFirstReady ? 'on' : 'off'](
Expand All @@ -64,7 +61,11 @@ export function fullscreenMap({

map.invalidateSize()
toggleFullscreenState()
setControlTitle(getFullscreenState())
setControlTitle({
fullscreen: getFullscreenState(),
linkAssign,
title,
})
},
)
}
Expand All @@ -73,7 +74,11 @@ export function fullscreenMap({
linkAssign({ href: '#' })

control.onAdd = function onControlAdd(addedMap) {
setControlTitle(getFullscreenState())
setControlTitle({
fullscreen: getFullscreenState(),
linkAssign,
title,
})

onLinkClick(async function handleLinkClick(e) {
DomEvent.stopPropagation(e)
Expand Down
3 changes: 3 additions & 0 deletions public/leaflet-fullscreen/set-control-title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function setControlTitle({ fullscreen, linkAssign, title }) {
linkAssign({ title: title[fullscreen] })
}

0 comments on commit 3d25705

Please sign in to comment.